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

Commitcbb2d9d

Browse files
committed
Improve relcache invalidation handling of currently invisible relations.
The corner case where a relcache invalidation tried to rebuild theentry for a referenced relation but couldn't find it in the catalogwasn't correct.The code tried to RelationCacheDelete/RelationDestroyRelation theentry. That didn't work when assertions are enabled because the lattercontains an assertion ensuring the refcount is zero. It's also moregenerally a bad idea, because by virtue of being referenced somebodymight actually look at the entry, which is possible if the error istrapped and handled via a subtransaction abort.Instead just error out, without deleting the entry. As the entry ismarked invalid, the worst that can happen is that the invalid (and atsome point unused) entry lingers in the relcache.Discussion: 22459.1418656530@sss.pgh.pa.usThere should be no way to hit this case < 9.4 where logical decodingintroduced a bug that can hit this. But since the code for handlingthe corner case is there it should do something halfway sane, sobackpatch all the the way back. The logical decoding bug will behandled in a separate commit.
1 parent9dcfb2b commitcbb2d9d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,9 +1976,13 @@ RelationClearRelation(Relation relation, bool rebuild)
19761976
newrel=RelationBuildDesc(save_relid, false);
19771977
if (newrel==NULL)
19781978
{
1979-
/* Should only get here if relation was deleted */
1980-
RelationCacheDelete(relation);
1981-
RelationDestroyRelation(relation);
1979+
/*
1980+
* This shouldn't happen as dropping a relation is intended to be
1981+
* impossible if still referenced (c.f. CheckTableNotInUse()). But
1982+
* if we get here anyway, we can't just delete the relcache entry,
1983+
* as it possibly could get accessed later (as e.g. the error
1984+
* might get trapped and handled via a subtransaction rollback).
1985+
*/
19821986
elog(ERROR,"relation %u deleted while still in use",save_relid);
19831987
}
19841988

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp