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

Commitaf0e7de

Browse files
committed
Don't destroy SMgrRelations at relcache invalidation
With commit21d9c3e, SMgrRelations remain valid until end oftransaction (or longer if they're "pinned"). Relcache invalidation canhappen in the middle of a transaction, so we must not destroy them atrelcache invalidation anymore.This was revealed by failures in the 'constraints' test in buildfarmanimals using -DCLOBBER_CACHE_ALWAYS. That started failing with commit8af2565, which was the first commit that started to rely on anSMgrRelation living until end of transaction.Diagnosed-by: Tomas Vondra, Thomas MunroReviewed-by: Thomas MunroDiscussion:https://www.postgresql.org/message-id/CA%2BhUKGK%2B5DOmLaBp3Z7C4S-Yv6yoROvr1UncjH2S1ZbPT8D%2BZg%40mail.gmail.com
1 parente629846 commitaf0e7de

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

‎src/backend/storage/smgr/smgr.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,6 @@ smgrdestroyall(void)
348348

349349
/*
350350
* smgrreleaseall() -- Release resources used by all objects.
351-
*
352-
* This is called for PROCSIGNAL_BARRIER_SMGRRELEASE.
353351
*/
354352
void
355353
smgrreleaseall(void)

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,9 +2985,6 @@ RelationCacheInvalidate(bool debug_discard)
29852985
{
29862986
relation=idhentry->reldesc;
29872987

2988-
/* Must close all smgr references to avoid leaving dangling ptrs */
2989-
RelationCloseSmgr(relation);
2990-
29912988
/*
29922989
* Ignore new relations; no other backend will manipulate them before
29932990
* we commit. Likewise, before replacing a relation's relfilelocator,
@@ -3039,11 +3036,10 @@ RelationCacheInvalidate(bool debug_discard)
30393036
}
30403037

30413038
/*
3042-
* Now zap any remaining smgr cache entries. This must happen before we
3043-
* start to rebuild entries, since that may involve catalog fetches which
3044-
* will re-open catalog files.
3039+
* We cannot destroy the SMgrRelations as there might still be references
3040+
* to them, but close the underlying file descriptors.
30453041
*/
3046-
smgrdestroyall();
3042+
smgrreleaseall();
30473043

30483044
/* Phase 2: rebuild the items found to need rebuild in phase 1 */
30493045
foreach(l,rebuildFirstList)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp