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

Commita0e2a17

Browse files
committed
Ensure snapshot is registered within ScanPgRelation().
In 9.4 I added support to use a historical snapshot inScanPgRelation(), while adding logical decoding. Unfortunately aconflict with the concurrent removal of SnapshotNow was incorrectlyresolved, leading to an unregistered snapshot being used.It is not correct to use an unregistered (or non-active) snapshot foranything non-trivial, because catalog invalidations can cause thesnapshot to be invalidated.Luckily it seems unlikely to actively cause problems in practice, asScanPgRelation() requires that we already have a lock on the relation,we only look for a single row, and we don't appear to rely on theresult's tid to be correct. It however is clearly wrong and potentialnegative consequences would likely be hard to find. So it seems worthbackpatching the fix, even without a concrete hazard.Discussion:https://postgr.es/m/20200229052459.wzhqnbhrriezg4v2@alap3.anarazel.deBackpatch: 9.5-
1 parent42d3649 commita0e2a17

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ ScanPgRelation(Oid targetRelId, bool indexOK, bool force_non_historic)
312312
Relationpg_class_desc;
313313
SysScanDescpg_class_scan;
314314
ScanKeyDatakey[1];
315-
Snapshotsnapshot;
315+
Snapshotsnapshot=NULL;
316316

317317
/*
318318
* If something goes wrong during backend startup, we might find ourselves
@@ -342,12 +342,12 @@ ScanPgRelation(Oid targetRelId, bool indexOK, bool force_non_historic)
342342
/*
343343
* The caller might need a tuple that's newer than the one the historic
344344
* snapshot; currently the only case requiring to do so is looking up the
345-
* relfilenode of non mapped system relations during decoding.
345+
* relfilenode of non mapped system relations during decoding. That
346+
* snapshot cant't change in the midst of a relcache build, so there's no
347+
* need to register the snapshot.
346348
*/
347349
if (force_non_historic)
348350
snapshot=GetNonHistoricCatalogSnapshot(RelationRelationId);
349-
else
350-
snapshot=GetCatalogSnapshot(RelationRelationId);
351351

352352
pg_class_scan=systable_beginscan(pg_class_desc,ClassOidIndexId,
353353
indexOK&&criticalRelcachesBuilt,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp