From dcedfdafce82ae65656e32468d84b084e629a70b Mon Sep 17 00:00:00 2001 From: Petr Jelinek Date: Tue, 21 Feb 2017 20:14:44 +0100 Subject: [PATCH 2/3] Don't use on disk snapshots for snapshot export in logical decoding We store historical snapshots on disk to enable continuation of logical decoding after restart. These snapshots were reused by the slot initialization code when searching for consistent snapshot. However these snapshots are only useful for catalogs and not for normal user tables. So when we exported such snapshots for user to read data from tables that is consistent with a specific LSN of slot creation, user would instead read wrong data. There does not seem to be simple way to make the logical decoding historical snapshots useful for normal tables so don't use them for exporting at all for now. --- src/backend/replication/logical/snapbuild.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index c2476a9..0b10044 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -1252,11 +1252,11 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn { /* --- * Build catalog decoding snapshot incrementally using information about - * the currently running transactions. There are several ways to do that: + * the currently running transactions. There are couple ways to do that: * * a) There were no running transactions when the xl_running_xacts record * was inserted, jump to CONSISTENT immediately. We might find such a - * state we were waiting for b) and c). + * state we were waiting for b). * * b) Wait for all toplevel transactions that were running to end. We * simply track the number of in-progress toplevel transactions and @@ -1269,9 +1269,6 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn * Interestingly, in contrast to HS, this allows us not to care about * subtransactions - and by extension suboverflowed xl_running_xacts - * at all. - * - * c) This (in a previous run) or another decoding slot serialized a - * snapshot to disk that we can use. * --- */ @@ -1326,13 +1323,6 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn return false; } - /* c) valid on disk state */ - else if (SnapBuildRestore(builder, lsn)) - { - /* there won't be any state to cleanup */ - return false; - } - /* * b) first encounter of a useable xl_running_xacts record. If we had * found one earlier we would either track running transactions (i.e. -- 2.7.4