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

Commitdbca84f

Browse files
committed
In rebuild_relation(), don't access an already-closed relcache entry.
This reliably fails with -DRELCACHE_FORCE_RELEASE, as reported byAndrew Dunstan, and could sometimes fail in normal operation, resultingin a wrong persistence value being used for the transient table.It's not immediately clear to me what effects that might have beyondthe risk of a crash while accessing OldHeap->rd_rel->relpersistence,but it's probably not good.Bug introduced by commitf41872d, and made substantially worse bycommit85b506b, which added a second such access significantlylater than the heap_close. I doubt the first reference could failin a production scenario, but the second one definitely could.Discussion:https://postgr.es/m/7b52f900-0579-cda9-ae2e-de5da17090e6@2ndQuadrant.com
1 parentd77ff69 commitdbca84f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎src/backend/commands/cluster.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid, bool verbose)
557557
OidtableOid=RelationGetRelid(OldHeap);
558558
OidtableSpace=OldHeap->rd_rel->reltablespace;
559559
OidOIDNewHeap;
560+
charrelpersistence;
560561
boolis_system_catalog;
561562
boolswap_toast_by_content;
562563
TransactionIdfrozenXid;
@@ -566,15 +567,16 @@ rebuild_relation(Relation OldHeap, Oid indexOid, bool verbose)
566567
if (OidIsValid(indexOid))
567568
mark_index_clustered(OldHeap,indexOid, true);
568569

569-
/* Remember if it's a system catalog */
570+
/* Remember info about rel before closing OldHeap */
571+
relpersistence=OldHeap->rd_rel->relpersistence;
570572
is_system_catalog=IsSystemRelation(OldHeap);
571573

572574
/* Close relcache entry, but keep lock until transaction commit */
573575
heap_close(OldHeap,NoLock);
574576

575577
/* Create the transient table that will receive the re-ordered data */
576578
OIDNewHeap=make_new_heap(tableOid,tableSpace,
577-
OldHeap->rd_rel->relpersistence,
579+
relpersistence,
578580
AccessExclusiveLock);
579581

580582
/* Copy the heap data into the new table in the desired order */
@@ -588,7 +590,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid, bool verbose)
588590
finish_heap_swap(tableOid,OIDNewHeap,is_system_catalog,
589591
swap_toast_by_content, false, true,
590592
frozenXid,cutoffMulti,
591-
OldHeap->rd_rel->relpersistence);
593+
relpersistence);
592594
}
593595

594596

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp