mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Advance backend's advertised xmin more aggressively.
Currently, a backend will reset it's PGXACT->xmin value when it doesn't have any registered snapshots left. That covered the common case that a transaction in read committed mode runs several queries, one after each other, as there would be no snapshots active between those queries. However, if you hold cursors across each of the query, we didn't get a chance to reset xmin. To make that better, keep all the registered snapshots in a pairing heap, ordered by xmin so that it's always quick to find the snapshot with the smallest xmin. That allows us to advance PGXACT->xmin whenever the oldest snapshot is deregistered, even if there are others still active. Per discussion originally started by Jeff Davis back in 2009 and more recently by Robert Haas.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#define SNAPSHOT_H
|
||||
|
||||
#include "access/htup.h"
|
||||
#include "lib/pairingheap.h"
|
||||
#include "storage/buf.h"
|
||||
|
||||
|
||||
@@ -91,7 +92,9 @@ typedef struct SnapshotData
|
||||
*/
|
||||
CommandId curcid; /* in my xact, CID < curcid are visible */
|
||||
uint32 active_count; /* refcount on ActiveSnapshot stack */
|
||||
uint32 regd_count; /* refcount on RegisteredSnapshotList */
|
||||
uint32 regd_count; /* refcount on RegisteredSnapshots */
|
||||
|
||||
pairingheap_node ph_node; /* link in the RegisteredSnapshots heap */
|
||||
} SnapshotData;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user