Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 67bab53

Browse files
committed
Fix parallel worker tracking of new catalog relfilenumbers.
Reunite RestorePendingSyncs() with RestoreRelationMap(). If RelationInitPhysicalAddr() ran after RestoreRelationMap() but before RestorePendingSyncs(), the relcache entry could cause RelationNeedsWAL() to return true erroneously. Trouble required commands of the current transaction to include REINDEX or CLUSTER of a system catalog. The parallel leader correctly derived RelationNeedsWAL()==false from the new relfilenumber, but the worker saw RelationNeedsWAL()==true. Worker MarkBufferDirtyHint() then wrote unwanted WAL. Recovery of that unwanted WAL could lose tuples like the system could before commit c6b9204 introduced this tracking. RestorePendingSyncs() and RestoreRelationMap() were adjacent till commit 126ec0b, so no back-patch for now. Reviewed by Tom Lane. Discussion: https://postgr.es/m/20241019232815.c6.nmisch@google.com
1 parent e947224 commit 67bab53

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/backend/access/transam/parallel.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,17 +1421,18 @@ ParallelWorkerMain(Datum main_arg)
14211421
StartParallelWorkerTransaction(tstatespace);
14221422

14231423
/*
1424-
* Restore relmapper and reindex state early, since these affect catalog
1425-
* access. Ideally we'd do this even before calling InitPostgres, but
1426-
* that has order-of-initialization problems, and also the relmapper would
1427-
* get confused during the CommitTransactionCommand call above.
1424+
* Restore state that affects catalog access. Ideally we'd do this even
1425+
* before calling InitPostgres, but that has order-of-initialization
1426+
* problems, and also the relmapper would get confused during the
1427+
* CommitTransactionCommand call above.
14281428
*/
1429+
pendingsyncsspace = shm_toc_lookup(toc, PARALLEL_KEY_PENDING_SYNCS,
1430+
false);
1431+
RestorePendingSyncs(pendingsyncsspace);
14291432
relmapperspace = shm_toc_lookup(toc, PARALLEL_KEY_RELMAPPER_STATE, false);
14301433
RestoreRelationMap(relmapperspace);
14311434
reindexspace = shm_toc_lookup(toc, PARALLEL_KEY_REINDEX_STATE, false);
14321435
RestoreReindexState(reindexspace);
1433-
1434-
/* Restore combo CID state. */
14351436
combocidspace = shm_toc_lookup(toc, PARALLEL_KEY_COMBO_CID, false);
14361437
RestoreComboCIDState(combocidspace);
14371438

@@ -1488,11 +1489,6 @@ ParallelWorkerMain(Datum main_arg)
14881489
SetTempNamespaceState(fps->temp_namespace_id,
14891490
fps->temp_toast_namespace_id);
14901491

1491-
/* Restore pending syncs. */
1492-
pendingsyncsspace = shm_toc_lookup(toc, PARALLEL_KEY_PENDING_SYNCS,
1493-
false);
1494-
RestorePendingSyncs(pendingsyncsspace);
1495-
14961492
/* Restore uncommitted enums. */
14971493
uncommittedenumsspace = shm_toc_lookup(toc, PARALLEL_KEY_UNCOMMITTEDENUMS,
14981494
false);

0 commit comments

Comments
 (0)