Fix rd_firstRelfilenodeSubid for nailed relations, in parallel workers.
Move applicable code out of RelationBuildDesc(), which nailed relations bypass. Non-assert builds experienced no known problems. Back-patch to v13, where commit c6b92041d38512a4176ed76ad06f713d2e6c01a8 introduced rd_firstRelfilenodeSubid. Kyotaro Horiguchi. Reported by Justin Pryzby. Discussion: https://postgr.es/m/20200907023737.GA7158@telsasoft.com
This commit is contained in:
parent
35e59398ab
commit
6f15be5bed
23
src/backend/utils/cache/relcache.c
vendored
23
src/backend/utils/cache/relcache.c
vendored
@ -1242,14 +1242,6 @@ RelationBuildDesc(Oid targetRelId, bool insertIt)
|
|||||||
if (insertIt)
|
if (insertIt)
|
||||||
RelationCacheInsert(relation, true);
|
RelationCacheInsert(relation, true);
|
||||||
|
|
||||||
/*
|
|
||||||
* For RelationNeedsWAL() to answer correctly on parallel workers, restore
|
|
||||||
* rd_firstRelfilenodeSubid. No subtransactions start or end while in
|
|
||||||
* parallel mode, so the specific SubTransactionId does not matter.
|
|
||||||
*/
|
|
||||||
if (IsParallelWorker() && RelFileNodeSkippingWAL(relation->rd_node))
|
|
||||||
relation->rd_firstRelfilenodeSubid = TopSubTransactionId;
|
|
||||||
|
|
||||||
/* It's fully valid */
|
/* It's fully valid */
|
||||||
relation->rd_isvalid = true;
|
relation->rd_isvalid = true;
|
||||||
|
|
||||||
@ -1272,6 +1264,8 @@ RelationBuildDesc(Oid targetRelId, bool insertIt)
|
|||||||
static void
|
static void
|
||||||
RelationInitPhysicalAddr(Relation relation)
|
RelationInitPhysicalAddr(Relation relation)
|
||||||
{
|
{
|
||||||
|
Oid oldnode = relation->rd_node.relNode;
|
||||||
|
|
||||||
/* these relations kinds never have storage */
|
/* these relations kinds never have storage */
|
||||||
if (!RELKIND_HAS_STORAGE(relation->rd_rel->relkind))
|
if (!RELKIND_HAS_STORAGE(relation->rd_rel->relkind))
|
||||||
return;
|
return;
|
||||||
@ -1329,6 +1323,19 @@ RelationInitPhysicalAddr(Relation relation)
|
|||||||
elog(ERROR, "could not find relation mapping for relation \"%s\", OID %u",
|
elog(ERROR, "could not find relation mapping for relation \"%s\", OID %u",
|
||||||
RelationGetRelationName(relation), relation->rd_id);
|
RelationGetRelationName(relation), relation->rd_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For RelationNeedsWAL() to answer correctly on parallel workers, restore
|
||||||
|
* rd_firstRelfilenodeSubid. No subtransactions start or end while in
|
||||||
|
* parallel mode, so the specific SubTransactionId does not matter.
|
||||||
|
*/
|
||||||
|
if (IsParallelWorker() && oldnode != relation->rd_node.relNode)
|
||||||
|
{
|
||||||
|
if (RelFileNodeSkippingWAL(relation->rd_node))
|
||||||
|
relation->rd_firstRelfilenodeSubid = TopSubTransactionId;
|
||||||
|
else
|
||||||
|
relation->rd_firstRelfilenodeSubid = InvalidSubTransactionId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -36,3 +36,13 @@ REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
|
|||||||
REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
|
REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
|
||||||
REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
|
REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
|
||||||
REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
|
REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
|
||||||
|
-- Check the same REINDEX INDEX statements under parallelism.
|
||||||
|
BEGIN;
|
||||||
|
SET min_parallel_table_scan_size = 0;
|
||||||
|
REINDEX INDEX pg_class_oid_index; -- mapped, non-shared, critical
|
||||||
|
REINDEX INDEX pg_class_relname_nsp_index; -- mapped, non-shared, non-critical
|
||||||
|
REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
|
||||||
|
REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
|
||||||
|
REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
|
||||||
|
REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
|
||||||
|
ROLLBACK;
|
||||||
|
@ -39,3 +39,14 @@ REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
|
|||||||
REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
|
REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
|
||||||
REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
|
REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
|
||||||
REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
|
REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
|
||||||
|
|
||||||
|
-- Check the same REINDEX INDEX statements under parallelism.
|
||||||
|
BEGIN;
|
||||||
|
SET min_parallel_table_scan_size = 0;
|
||||||
|
REINDEX INDEX pg_class_oid_index; -- mapped, non-shared, critical
|
||||||
|
REINDEX INDEX pg_class_relname_nsp_index; -- mapped, non-shared, non-critical
|
||||||
|
REINDEX INDEX pg_index_indexrelid_index; -- non-mapped, non-shared, critical
|
||||||
|
REINDEX INDEX pg_index_indrelid_index; -- non-mapped, non-shared, non-critical
|
||||||
|
REINDEX INDEX pg_database_oid_index; -- mapped, shared, critical
|
||||||
|
REINDEX INDEX pg_shdescription_o_c_index; -- mapped, shared, non-critical
|
||||||
|
ROLLBACK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user