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

Commit5236dcd

Browse files
committed
Fix creation of partition descriptor during concurrent detach+drop
If a partition undergoes DETACH CONCURRENTLY immediately followed byDROP, this could cause a problem for a concurrent transactionrecomputing the partition descriptor when running a prepared statement,because it tries to dereference a pointer to a tuple that's not found ina catalog scan.The existing retry logic added in commitdbca346 is sufficient tocope with the overall problem, provided we don't try to dereference anon-existant heap tuple.Arguably, the code in RelationBuildPartitionDesc() has been wrong allalong, since no check was added in commit898e5e3 against receivinga NULL tuple from the catalog scan; that bug has only becomeuser-visible with DETACH CONCURRENTLY which was added in branch 14.Therefore, even though there's no known mechanism to cause a crashbecause of this, backpatch the addition of such a check to all supportedbranches. In branches prior to 14, this would cause the code to failwith a "missing relpartbound for relation XYZ" error instead ofcrashing; that's okay, because there are no reports of such behavioranyway.Author: Kuntal Ghosh <kuntalghosh.2007@gmail.com>Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>Reviewed-by: Tender Wang <tndrwang@gmail.com>Discussion:https://postgr.es/m/18559-b48286d2eacd9a4e@postgresql.org
1 parent016f443 commit5236dcd

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

‎src/backend/partitioning/partdesc.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ RelationBuildPartitionDesc(Relation rel)
164164
Relationpg_class;
165165
SysScanDescscan;
166166
ScanKeyDatakey[1];
167-
Datumdatum;
168-
boolisnull;
169167

170168
pg_class=table_open(RelationRelationId,AccessShareLock);
171169
ScanKeyInit(&key[0],
@@ -175,10 +173,16 @@ RelationBuildPartitionDesc(Relation rel)
175173
scan=systable_beginscan(pg_class,ClassOidIndexId, true,
176174
NULL,1,key);
177175
tuple=systable_getnext(scan);
178-
datum=heap_getattr(tuple,Anum_pg_class_relpartbound,
179-
RelationGetDescr(pg_class),&isnull);
180-
if (!isnull)
181-
boundspec=stringToNode(TextDatumGetCString(datum));
176+
if (HeapTupleIsValid(tuple))
177+
{
178+
Datumdatum;
179+
boolisnull;
180+
181+
datum=heap_getattr(tuple,Anum_pg_class_relpartbound,
182+
RelationGetDescr(pg_class),&isnull);
183+
if (!isnull)
184+
boundspec=stringToNode(TextDatumGetCString(datum));
185+
}
182186
systable_endscan(scan);
183187
table_close(pg_class,AccessShareLock);
184188
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp