Re: snapbuild woes
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>, Erik Rijkers <er@xs4all.nl>, Robert Haas <robertmhaas@gmail.com>, Craig Ringer <craig@2ndquadrant.com>
Date: 2017-05-11T22:12:17Z
Lists: pgsql-hackers
On 2017-04-15 05:18:49 +0200, Petr Jelinek wrote: > >>> From 3318a929e691870f3c1ca665bec3bfa8ea2af2a8 Mon Sep 17 00:00:00 2001 > >>> From: Petr Jelinek <pjmodos@pjmodos.net> > >>> Date: Sun, 26 Feb 2017 01:07:33 +0100 > >>> Subject: [PATCH 3/5] Prevent snapshot builder xmin from going backwards > >> > >> A bit more commentary would be good. What does that protect us against? > >> > > > > I think I explained that in the email. We might export snapshot with > > xmin smaller than global xmin otherwise. > > > > Updated commit message with explanation as well. > From ae60b52ae0ca96bc14169cd507f101fbb5dfdf52 Mon Sep 17 00:00:00 2001 > From: Petr Jelinek <pjmodos@pjmodos.net> > Date: Sun, 26 Feb 2017 01:07:33 +0100 > Subject: [PATCH 3/5] Prevent snapshot builder xmin from going backwards > > Logical decoding snapshot builder may encounter xl_running_xacts with > older xmin than the xmin of the builder. This can happen because > LogStandbySnapshot() sometimes sees already committed transactions as > running (there is difference between "running" in terms for WAL and in > terms of ProcArray). When this happens we must make sure that the xmin > of snapshot builder won't go back otherwise the resulting snapshot would > show some transaction as running even though they have already > committed. > --- > src/backend/replication/logical/snapbuild.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c > index ada618d..3e34f75 100644 > --- a/src/backend/replication/logical/snapbuild.c > +++ b/src/backend/replication/logical/snapbuild.c > @@ -1165,7 +1165,8 @@ SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, xl_running_xact > * looking, it's correct and actually more efficient this way since we hit > * fast paths in tqual.c. > */ > - builder->xmin = running->oldestRunningXid; > + if (TransactionIdFollowsOrEquals(running->oldestRunningXid, builder->xmin)) > + builder->xmin = running->oldestRunningXid; > > /* Remove transactions we don't need to keep track off anymore */ > SnapBuildPurgeCommittedTxn(builder); > -- > 2.7.4 I still don't understand. The snapshot's xmin is solely managed via xl_running_xacts, so I don't see how the WAL/procarray difference can play a role here. ->committed isn't pruned before xl_running_xacts indicates it can be done, so I don't understand your explanation above. I'd be ok with adding this as paranoia check, but I still don't understand when it could practically be hit. - Andres
Commits
-
Fix thinko introduced in 2bef06d516460 et al.
- d68742562ca4 9.4.13 landed
- 869a5869e5ba 9.5.8 landed
- 32d7480e02ee 9.6.4 landed
- 5af4456a5647 10.0 landed
-
Avoid superfluous work for commits during logical slot creation.
- fa9207c7415c 9.5.8 landed
- bd619fcfe046 9.6.4 landed
- 524dbc14335c 10.0 landed
- 2dca50b764d4 9.4.13 landed
-
Fix race condition leading to hanging logical slot creation.
- b64a68e3680a 9.5.8 landed
- 955a684e0401 10.0 landed
- 79abd23db1e9 9.4.13 landed
- 75784859cda2 9.6.4 landed
-
Don't use on-disk snapshots for exported logical decoding snapshot.
- b6ecf26ccc2b 9.4.12 landed
- 54270d7ebcdc 9.5.7 landed
- 29e8c881dd07 9.6.3 landed
- 56e19d938dd1 10.0 landed
-
Preserve required !catalog tuples while computing initial decoding snapshot.
- 5da64613875d 9.4.12 landed
- 47f896b5c2ec 9.5.7 landed
- 2bef06d51646 10.0 landed
- 28afff347a5d 9.6.3 landed