Skip to content

Commit 80c79ab

Browse files
committed
pgstattuple: Use SnapshotDirty, not SnapshotNow.
Tuples belonging to uncommitted transactions should not be counted as dead. This is arguably a bug fix that should be back-patched, but as no one ever noticed until it came time to try to get rid of SnapshotNow, I'm only doing this in master for now.
1 parent 3483f43 commit 80c79ab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

contrib/pgstattuple/pgstattuple.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,11 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
278278
Buffer buffer;
279279
pgstattuple_type stat = {0};
280280
BufferAccessStrategy bstrategy;
281+
SnapshotData SnapshotDirty;
281282

282283
/* Disable syncscan because we assume we scan from block zero upwards */
283284
scan = heap_beginscan_strat(rel, SnapshotAny, 0, NULL, true, false);
285+
InitDirtySnapshot(SnapshotDirty);
284286

285287
nblocks = scan->rs_nblocks; /* # blocks to be scanned */
286288

@@ -296,7 +298,7 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
296298
/* must hold a buffer lock to call HeapTupleSatisfiesVisibility */
297299
LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
298300

299-
if (HeapTupleSatisfiesVisibility(tuple, SnapshotNow, scan->rs_cbuf))
301+
if (HeapTupleSatisfiesVisibility(tuple, &SnapshotDirty, scan->rs_cbuf))
300302
{
301303
stat.tuple_len += tuple->t_len;
302304
stat.tuple_count++;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy