]> granicus.if.org Git - postgresql/commit
Advance backend's advertised xmin more aggressively.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 16 Jan 2015 23:14:32 +0000 (01:14 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 16 Jan 2015 23:15:23 +0000 (01:15 +0200)
commit94028691609f8e148bd4ce72c46163f018832a5b
treeb27e0466f02336d5dad3f2594942e9a4cc23b4c2
parent779fdcdeeeb9cdbfd271f8dc5bde76ed0c7b0813
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.
src/backend/utils/time/snapmgr.c
src/include/lib/pairingheap.h
src/include/utils/snapshot.h