aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/init/postinit.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-12-23 12:42:39 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-12-23 12:42:39 +0200
commit952365cded635e54c4177399c0280cb7a5e34c11 (patch)
treeb73b5b3452acfbb3acb3cce049272d13a3ed0435 /src/backend/utils/init/postinit.c
parent7ec4b9ff80d92fee3c41eb1a069cc32d0ec11da1 (diff)
downloadpostgresql-952365cded635e54c4177399c0280cb7a5e34c11.tar.gz
postgresql-952365cded635e54c4177399c0280cb7a5e34c11.zip
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/7c56f180-b9e1-481e-8c1d-efa63de3ecbb@iki.fi
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r--src/backend/utils/init/postinit.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 5b657a3f135..770ab6906e7 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -813,16 +813,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
}
/*
- * Start a new transaction here before first access to db, 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 new transaction here before first access to db.
*/
if (!bootstrap)
{
@@ -837,8 +828,6 @@ InitPostgres(const char *in_dbname, Oid dboid,
* Fortunately, "read committed" is plenty good enough.
*/
XactIsoLevel = XACT_READ_COMMITTED;
-
- (void) GetTransactionSnapshot();
}
/*