diff options
author | Heikki Linnakangas | 2024-12-23 10:42:39 +0000 |
---|---|---|
committer | Heikki Linnakangas | 2024-12-23 10:42:39 +0000 |
commit | 952365cded635e54c4177399c0280cb7a5e34c11 (patch) | |
tree | b73b5b3452acfbb3acb3cce049272d13a3ed0435 /src/backend/replication/logical | |
parent | 7ec4b9ff80d92fee3c41eb1a069cc32d0ec11da1 (diff) |
Remove unnecessary GetTransactionSnapshot() calls
In get_database_list() and get_subscription_list(), the
GetTransactionSnapshot() call is not required because the catalog
table scans use the catalog snapshot, which is held until the end of
the scan. See table_beginscan_catalog(), which calls
RegisterSnapshot(GetCatalogSnapshot(relid)).
In InitPostgres, it's a little less obvious that it's not required,
but still true I believe. All the catalog lookups in InitPostgres()
also use the catalog snapshot, and the looked up values are copied
while still holding the snapshot.
Furthermore, as the removed FIXME comments said, calling
GetTransactionSnapshot() didn't really prevent MyProc->xmin from being
reset anyway.
Discussion: https://www.postgresql.org/message-id/[email protected]
Diffstat (limited to 'src/backend/replication/logical')
-rw-r--r-- | src/backend/replication/logical/launcher.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index e5fdca8bbf6..8b196420445 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -121,18 +121,9 @@ get_subscription_list(void) resultcxt = CurrentMemoryContext; /* - * Start a transaction so we can access pg_database, and get a snapshot. - * We don't have a use for the snapshot itself, but we're interested in - * the secondary effect that it sets RecentGlobalXmin. (This is critical - * for anything that reads heap pages, because HOT may decide to prune - * them even if the process doesn't attempt to modify any tuples.) - * - * FIXME: This comment is inaccurate / the code buggy. A snapshot that is - * not pushed/active does not reliably prevent HOT pruning (->xmin could - * e.g. be cleared when cache invalidations are processed). + * Start a transaction so we can access pg_subscription. */ StartTransactionCommand(); - (void) GetTransactionSnapshot(); rel = table_open(SubscriptionRelationId, AccessShareLock); scan = table_beginscan_catalog(rel, 0, NULL); |