From: Andres Freund Date: Sun, 6 Aug 2017 03:52:53 +0000 (-0700) Subject: Fix thinko introduced in 2bef06d516460 et al. X-Git-Tag: REL9_5_8~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=869a5869e5ba7be0870c552e987158659d450e6c;p=thirdparty%2Fpostgresql.git Fix thinko introduced in 2bef06d516460 et al. The callers for GetOldestSafeDecodingTransactionId() all inverted the argument for the argument introduced in 2bef06d516460. Luckily this appears to be inconsequential for the moment, as we wait for concurrent in-progress transaction when assembling a snapshot. Additionally this could only make a difference when adding a second logical slot, because only a pre-existing slot could cause an issue by lowering the returned xid dangerously much. Reported-By: Antonin Houska Discussion: https://postgr.es/m/32704.1496993134@localhost Backport: 9.4-, where 2bef06d516460 was backpatched to. --- diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c index 1b92c056b89..855f0035410 100644 --- a/src/backend/replication/logical/logical.c +++ b/src/backend/replication/logical/logical.c @@ -327,7 +327,7 @@ CreateInitDecodingContext(char *plugin, */ LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); - xmin_horizon = GetOldestSafeDecodingTransactionId(need_full_snapshot); + xmin_horizon = GetOldestSafeDecodingTransactionId(!need_full_snapshot); slot->effective_catalog_xmin = xmin_horizon; slot->data.catalog_xmin = xmin_horizon; diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index 981f3978323..f4b1fea0f84 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -594,7 +594,7 @@ SnapBuildExportSnapshot(SnapBuild *builder) TransactionId safeXid; LWLockAcquire(ProcArrayLock, LW_SHARED); - safeXid = GetOldestSafeDecodingTransactionId(true); + safeXid = GetOldestSafeDecodingTransactionId(false); LWLockRelease(ProcArrayLock); Assert(TransactionIdPrecedesOrEquals(safeXid, snap->xmin));