summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorKevin Grittner <kgrittn@postgresql.org>2015-01-30 08:57:24 -0600
committerKevin Grittner <kgrittn@postgresql.org>2015-01-30 08:57:24 -0600
commitcff1bd2a3c36fdf014367dd97f140495ef6ed47e (patch)
tree9128cc99728739c1049146e724f58e5507a77ee5 /src/bin
parent32bf6ee6ab5cdfa4247f984f864860d988a58dfe (diff)
downloadpostgresql-cff1bd2a3c36fdf014367dd97f140495ef6ed47e.tar.gz
Allow pg_dump to use jobs and serializable transactions together.
Since 9.3, when the --jobs option was introduced, using it together with the --serializable-deferrable option generated multiple errors. We can get correct behavior by allowing the connection which acquires the snapshot to use SERIALIZABLE, READ ONLY, DEFERRABLE and pass that to the workers running the other connections using REPEATABLE READ, READ ONLY. This is a bit of a kluge since the SERIALIZABLE behavior is achieved by running some of the participating connections at a different isolation level, but it is a simple and safe change, suitable for back-patching. This will be followed by a proposal for a more invasive fix with some slight behavioral changes on just the master branch, based on suggestions from Andres Freund, but the kluge will be applied to master until something is agreed along those lines. Back-patched to 9.3, where the --jobs option was added. Based on report from Alexander Korotkov
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_dump/pg_dump.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index c3ebb3a9b0..abebdacfdc 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1011,7 +1011,15 @@ setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding,
ExecuteSqlStatement(AH, "BEGIN");
if (AH->remoteVersion >= 90100)
{
- if (dopt->serializable_deferrable)
+ /*
+ * To support the combination of serializable_deferrable with the jobs
+ * option we use REPEATABLE READ for the worker connections that are
+ * passed a snapshot. As long as the snapshot is acquired in a
+ * SERIALIZABLE, READ ONLY, DEFERRABLE transaction, its use within a
+ * REPEATABLE READ transaction provides the appropriate integrity
+ * guarantees. This is a kluge, but safe for back-patching.
+ */
+ if (dopt->serializable_deferrable && AH->sync_snapshot_id == NULL)
ExecuteSqlStatement(AH,
"SET TRANSACTION ISOLATION LEVEL "
"SERIALIZABLE, READ ONLY, DEFERRABLE");