Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb02fc7d

Browse files
committed
Fix ordering issue with WAL operations in GIN fast insert path
Contrary to what is documented in src/backend/access/transam/README,ginHeapTupleFastInsert() had a few ordering issues with the way it doesits WAL operations when inserting items in its fast path.First, when using a separate list, XLogBeginInsert() was being alwayscalled before START_CRIT_SECTION(), and in this case a second thing waswrong when merging lists, as an exclusive lock was taken on the tailpage *before* calling XLogBeginInsert(). Finally, when inserting itemsinto a tail page, the order of XLogBeginInsert() andSTART_CRIT_SECTION() was reversed. This commit addresses all theseissues by moving the calls of XLogBeginInsert() after all the pageslogged are locked and pinned, within a critical section.This has been applied first only on HEAD as of56b6625, but as perdiscussion with Tom Lane and Álvaro Herrera, a backpatch is preferred tokeep all the branches consistent and to respect the transam's READMEwhere we can.Author: Matthias van de Meent, Zhang MingliDiscussion:https://postgr.es/m/CAEze2WhL8uLMqynnnCu1LAPwxD5RKEo0nHV+eXGg_N6ELU88HQ@mail.gmail.comBackpatch-through: 10
1 parentba58266 commitb02fc7d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎src/backend/access/gin/ginfast.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector)
276276
memset(&sublist,0,sizeof(GinMetaPageData));
277277
makeSublist(index,collector->tuples,collector->ntuples,&sublist);
278278

279-
if (needWal)
280-
XLogBeginInsert();
281-
282279
/*
283280
* metapage was unlocked, see above
284281
*/
@@ -298,6 +295,9 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector)
298295

299296
metadata->nPendingPages=sublist.nPendingPages;
300297
metadata->nPendingHeapTuples=sublist.nPendingHeapTuples;
298+
299+
if (needWal)
300+
XLogBeginInsert();
301301
}
302302
else
303303
{
@@ -326,7 +326,10 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector)
326326
metadata->nPendingHeapTuples+=sublist.nPendingHeapTuples;
327327

328328
if (needWal)
329+
{
330+
XLogBeginInsert();
329331
XLogRegisterBuffer(1,buffer,REGBUF_STANDARD);
332+
}
330333
}
331334
}
332335
else
@@ -352,11 +355,11 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector)
352355

353356
data.ntuples=collector->ntuples;
354357

358+
START_CRIT_SECTION();
359+
355360
if (needWal)
356361
XLogBeginInsert();
357362

358-
START_CRIT_SECTION();
359-
360363
/*
361364
* Increase counter of heap tuples
362365
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp