Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cb01685

Browse files
committed
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
1 parent b170005 commit cb01685

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,15 @@ setup_connection(Archive *AH, const char *dumpencoding, char *use_role)
10141014
ExecuteSqlStatement(AH, "BEGIN");
10151015
if (AH->remoteVersion >= 90100)
10161016
{
1017-
if (serializable_deferrable)
1017+
/*
1018+
* To support the combination of serializable_deferrable with the jobs
1019+
* option we use REPEATABLE READ for the worker connections that are
1020+
* passed a snapshot. As long as the snapshot is acquired in a
1021+
* SERIALIZABLE, READ ONLY, DEFERRABLE transaction, its use within a
1022+
* REPEATABLE READ transaction provides the appropriate integrity
1023+
* guarantees. This is a kluge, but safe for back-patching.
1024+
*/
1025+
if (serializable_deferrable && AH->sync_snapshot_id == NULL)
10181026
ExecuteSqlStatement(AH,
10191027
"SET TRANSACTION ISOLATION LEVEL "
10201028
"SERIALIZABLE, READ ONLY, DEFERRABLE");

0 commit comments

Comments
 (0)