mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 15:16:29 +00:00
a12e71925958ed573aaeff29b0da02321543cf94
Phase 2
=======
Idea is that we keep a transaction running on primary with a snapshot
that prevents VACUUM from ever removing records that a query on the
standby can see. So there are never any query conflicts.
Make two connections to primary, P1 and P2. One to Standby, S.
P1:
BEGIN;
SELECT txid_current(); INTO Pn->xid
SELECT pg_sleep(10000000000);
P2:
BEGIN;
SELECT txid_current(); INTO Pn->xid
SELECT pg_sleep(10000000000);
Then every 1sec
S: GetOldestXmin() INTO S->xmin
/*
* If both P1 and P2 are older than oldest xmin on S
* then we cancel the oldest of P1 and P2, and
* start a new xid on that channel. So that P1 and P2
* slowly step forwards, as queries complete on the
* standby.
*/
if (TransactionIdPrecedes(P1->xid, S->xmin) &&
TransactionIdPrecedes(P2->xid, S->xmin))
{
if (TransactionIdPrecedes(P1->xid, P2->xid))
cancel_and_rerun(1)
else
cancel_and_rerun(2)
)
cancel_and_rerun()
{
cancel Pn
BEGIN;
SELECT txid_current(); INTO Pn->xid
SELECT pg_sleep(10000000000);
}
Releases
1
repmgr v5.5.0
Latest
Languages
C
98.1%
Lex
1.3%
Makefile
0.4%
Perl
0.2%