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

Commitbc49d93

Browse files
committed
Fix rare startup failure induced by MVCC-catalog-scans patch.
While a new backend nominally participates in sinval signaling startingfrom the SharedInvalBackendInit call near the top of InitPostgres, itcannot recognize sinval messages for unshared catalogs of its databaseuntil it has set up MyDatabaseId. This is not problematic for the catcacheor relcache, which by definition won't have loaded any data from or aboutsuch catalogs before that point. However, commit568d413introduced a mechanism for re-using MVCC snapshots for catalog scans, andmade invalidation of those depend on recognizing relevant sinval messages.So it's possible to establish a catalog snapshot to read pg_authid andpg_database, then before we set MyDatabaseId, receive sinval messages thatshould result in invalidating that snapshot --- but do not, because wedon't realize they are for our database. This mechanism explains theintermittent buildfarm failures we've seen since commit31eae60.That commit was not itself at fault, but it introduced a new regressiontest that does reconnections concurrently with the "vacuum full pg_am"command in vacuum.sql. This allowed the pre-existing error to be exposed,given just the right timing, because we'd fail to update our informationabout how to access pg_am. In principle any VACUUM FULL on a systemcatalog could have created a similar hazard for concurrent incomingconnections. Perhaps there are more subtle failure cases as well.To fix, force invalidation of the catalog snapshot as soon as we'veset MyDatabaseId.Back-patch to 9.4 where the error was introduced.
1 parent5e3d289 commitbc49d93

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎src/backend/utils/init/postinit.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,14 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
852852
/* (We assume this is an atomic store so no lock is needed) */
853853
MyProc->databaseId=MyDatabaseId;
854854

855+
/*
856+
* We established a catalog snapshot while reading pg_authid and/or
857+
* pg_database; but until we have set up MyDatabaseId, we won't react to
858+
* incoming sinval messages for unshared catalogs, so we won't realize it
859+
* if the snapshot has been invalidated. Assume it's no good anymore.
860+
*/
861+
InvalidateCatalogSnapshot();
862+
855863
/*
856864
* Now, take a writer's lock on the database we are trying to connect to.
857865
* If there is a concurrently running DROP DATABASE on that database, this

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp