diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c index 2b3dd1c677..a7a49b36fd 100644 --- a/src/backend/access/gin/ginfast.c +++ b/src/backend/access/gin/ginfast.c @@ -284,9 +284,6 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) memset(&sublist, 0, sizeof(GinMetaPageData)); makeSublist(index, collector->tuples, collector->ntuples, &sublist); - if (needWal) - XLogBeginInsert(); - /* * metapage was unlocked, see above */ @@ -306,6 +303,9 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) metadata->nPendingPages = sublist.nPendingPages; metadata->nPendingHeapTuples = sublist.nPendingHeapTuples; + + if (needWal) + XLogBeginInsert(); } else { @@ -334,7 +334,10 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) metadata->nPendingHeapTuples += sublist.nPendingHeapTuples; if (needWal) + { + XLogBeginInsert(); XLogRegisterBuffer(1, buffer, REGBUF_STANDARD); + } } } else @@ -360,11 +363,11 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) data.ntuples = collector->ntuples; + START_CRIT_SECTION(); + if (needWal) XLogBeginInsert(); - START_CRIT_SECTION(); - /* * Increase counter of heap tuples */