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

Commit6f15be5

Browse files
committed
Fix rd_firstRelfilenodeSubid for nailed relations, in parallel workers.
Move applicable code out of RelationBuildDesc(), which nailed relationsbypass. Non-assert builds experienced no known problems. Back-patch tov13, where commitc6b9204 introducedrd_firstRelfilenodeSubid.Kyotaro Horiguchi. Reported by Justin Pryzby.Discussion:https://postgr.es/m/20200907023737.GA7158@telsasoft.com
1 parent35e5939 commit6f15be5

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

‎src/backend/utils/cache/relcache.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,14 +1242,6 @@ RelationBuildDesc(Oid targetRelId, bool insertIt)
12421242
if (insertIt)
12431243
RelationCacheInsert(relation, true);
12441244

1245-
/*
1246-
* For RelationNeedsWAL() to answer correctly on parallel workers, restore
1247-
* rd_firstRelfilenodeSubid. No subtransactions start or end while in
1248-
* parallel mode, so the specific SubTransactionId does not matter.
1249-
*/
1250-
if (IsParallelWorker()&&RelFileNodeSkippingWAL(relation->rd_node))
1251-
relation->rd_firstRelfilenodeSubid=TopSubTransactionId;
1252-
12531245
/* It's fully valid */
12541246
relation->rd_isvalid= true;
12551247

@@ -1272,6 +1264,8 @@ RelationBuildDesc(Oid targetRelId, bool insertIt)
12721264
staticvoid
12731265
RelationInitPhysicalAddr(Relationrelation)
12741266
{
1267+
Oidoldnode=relation->rd_node.relNode;
1268+
12751269
/* these relations kinds never have storage */
12761270
if (!RELKIND_HAS_STORAGE(relation->rd_rel->relkind))
12771271
return;
@@ -1329,6 +1323,19 @@ RelationInitPhysicalAddr(Relation relation)
13291323
elog(ERROR,"could not find relation mapping for relation \"%s\", OID %u",
13301324
RelationGetRelationName(relation),relation->rd_id);
13311325
}
1326+
1327+
/*
1328+
* For RelationNeedsWAL() to answer correctly on parallel workers, restore
1329+
* rd_firstRelfilenodeSubid. No subtransactions start or end while in
1330+
* parallel mode, so the specific SubTransactionId does not matter.
1331+
*/
1332+
if (IsParallelWorker()&&oldnode!=relation->rd_node.relNode)
1333+
{
1334+
if (RelFileNodeSkippingWAL(relation->rd_node))
1335+
relation->rd_firstRelfilenodeSubid=TopSubTransactionId;
1336+
else
1337+
relation->rd_firstRelfilenodeSubid=InvalidSubTransactionId;
1338+
}
13321339
}
13331340

13341341
/*

‎src/test/regress/expected/reindex_catalog.out

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,13 @@ REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
3636
REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
3737
REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
3838
REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
39+
-- Check the same REINDEX INDEX statements under parallelism.
40+
BEGIN;
41+
SET min_parallel_table_scan_size = 0;
42+
REINDEX INDEX pg_class_oid_index; -- mapped, non-shared, critical
43+
REINDEX INDEX pg_class_relname_nsp_index; -- mapped, non-shared, non-critical
44+
REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
45+
REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
46+
REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
47+
REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
48+
ROLLBACK;

‎src/test/regress/sql/reindex_catalog.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,14 @@ REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
3939
REINDEX INDEX pg_index_indrelid_index;-- non-mapped, non-shared, non-critical
4040
REINDEX INDEX pg_database_oid_index;-- mapped, shared, critical
4141
REINDEX INDEX pg_shdescription_o_c_index;-- mapped, shared, non-critical
42+
43+
-- Check the same REINDEX INDEX statements under parallelism.
44+
BEGIN;
45+
SET min_parallel_table_scan_size=0;
46+
REINDEX INDEX pg_class_oid_index;-- mapped, non-shared, critical
47+
REINDEX INDEX pg_class_relname_nsp_index;-- mapped, non-shared, non-critical
48+
REINDEX INDEX pg_index_indexrelid_index;-- non-mapped, non-shared, critical
49+
REINDEX INDEX pg_index_indrelid_index;-- non-mapped, non-shared, non-critical
50+
REINDEX INDEX pg_database_oid_index;-- mapped, shared, critical
51+
REINDEX INDEX pg_shdescription_o_c_index;-- mapped, shared, non-critical
52+
ROLLBACK;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp