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

Commit126ec0b

Browse files
committed
Restore relmapper state early enough in parallel workers.
We need to do RestoreRelationMap before loading catalog-derivedstate, else the worker may end up with catalog relcache entriescontaining stale relfilenode data. Move up RestoreReindexStatetoo, on the principle that that should also happen before wedo much of any catalog access.I think ideally these things would happen even before InitPostgres,but there are various problems standing in the way of that, notablythat the relmapper thinks "active" mappings should be discarded attransaction end. The implication of this is that InitPostgres andRestoreLibraryState will see the same catalog state as an independentbackend would see, which is probably fine; at least, it's been likethat all along.Per report from Justin Pryzby. There is a case to be made thatthis should be back-patched. But given the lack of complaintsbefore6e086fa and the short amount of time remaining before17.0 wraps, I'll just put it in HEAD for now.Discussion:https://postgr.es/m/ZuoU_8EbSTE14o1U@pryzbyj2023
1 parent91287b5 commit126ec0b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

‎src/backend/access/transam/parallel.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,17 @@ ParallelWorkerMain(Datum main_arg)
14201420
tstatespace=shm_toc_lookup(toc,PARALLEL_KEY_TRANSACTION_STATE, false);
14211421
StartParallelWorkerTransaction(tstatespace);
14221422

1423+
/*
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.
1428+
*/
1429+
relmapperspace=shm_toc_lookup(toc,PARALLEL_KEY_RELMAPPER_STATE, false);
1430+
RestoreRelationMap(relmapperspace);
1431+
reindexspace=shm_toc_lookup(toc,PARALLEL_KEY_REINDEX_STATE, false);
1432+
RestoreReindexState(reindexspace);
1433+
14231434
/* Restore combo CID state. */
14241435
combocidspace=shm_toc_lookup(toc,PARALLEL_KEY_COMBO_CID, false);
14251436
RestoreComboCIDState(combocidspace);
@@ -1482,14 +1493,6 @@ ParallelWorkerMain(Datum main_arg)
14821493
false);
14831494
RestorePendingSyncs(pendingsyncsspace);
14841495

1485-
/* Restore reindex state. */
1486-
reindexspace=shm_toc_lookup(toc,PARALLEL_KEY_REINDEX_STATE, false);
1487-
RestoreReindexState(reindexspace);
1488-
1489-
/* Restore relmapper state. */
1490-
relmapperspace=shm_toc_lookup(toc,PARALLEL_KEY_RELMAPPER_STATE, false);
1491-
RestoreRelationMap(relmapperspace);
1492-
14931496
/* Restore uncommitted enums. */
14941497
uncommittedenumsspace=shm_toc_lookup(toc,PARALLEL_KEY_UNCOMMITTEDENUMS,
14951498
false);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp