pgsql: Don't force-assign transaction id when exporting a snapshot.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Don't force-assign transaction id when exporting a snapshot.
Date: 2017-06-14 18:57:29
Message-ID: E1dLDTt-0004AC-W5@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Don't force-assign transaction id when exporting a snapshot.

Previously we required every exported transaction to have an xid
assigned. That was used to check that the exporting transaction is
still running, which in turn is needed to guarantee that that
necessary rows haven't been removed in between exporting and importing
the snapshot.

The exported xid caused unnecessary problems with logical decoding,
because slot creation has to wait for all concurrent xid to finish,
which in turn serializes concurrent slot creation. It also
prohibited snapshots to be exported on hot-standby replicas.

Instead export the virtual transactionid, which avoids the unnecessary
serialization and the inability to export snapshots on standbys. This
changes the file name of the exported snapshot, but since we never
documented what that one means, that seems ok.

Author: Petr Jelinek, slightly editorialized by me
Reviewed-By: Andres Freund
Discussion: https://postgr.es/m/f598b4b8-8cd7-0d54-0939-adda763d8c34@2ndquadrant.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6c2003f8a1bbc7c192a2e83ec51581c018aa162f

Modified Files
--------------
doc/src/sgml/ref/set_transaction.sgml | 6 +-
src/backend/replication/logical/snapbuild.c | 14 ++--
src/backend/storage/ipc/procarray.c | 11 ++-
src/backend/storage/lmgr/predicate.c | 26 +++---
src/backend/utils/time/snapmgr.c | 119 ++++++++++++++++++----------
src/include/storage/predicate.h | 4 +-
src/include/storage/procarray.h | 2 +-
7 files changed, 115 insertions(+), 67 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2017-06-14 20:24:10 pgsql: Fix problems related to RangeTblEntry members enrname and enrtup
Previous Message Peter Eisentraut 2017-06-14 18:45:10 pgsql: Add missing serial comma

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2017-06-14 18:57:56 Re: logical replication busy-waiting on a lock
Previous Message Jeff Janes 2017-06-14 18:55:38 subscription worker signalling wal writer too much