Use read-write transaction to dump a database
authorPavan Deolasee <[email protected]>
Wed, 26 Sep 2018 17:11:59 +0000 (22:41 +0530)
committerPavan Deolasee <[email protected]>
Wed, 26 Sep 2018 17:11:59 +0000 (22:41 +0530)
In XL we use nextval() to get a consistent value of a sequence since different
nodes may have stale view of the sequence and hence we must obtain a value from
the GTM. Calling nextval() though requires us to execute the transaction in
read-write mode. So we do that. It shouldn't be a big deal since pg_dump is
very careful about only reading from the database (it was only recently the
transaction was made read-only). More to the point, in XL we'd never used
read-only transaction while dumping a database, but by default direct
connection to a datanode are treated as read-only transaction and hence merely
removing READ ONLY transaction attribute wasn't enough. We had to explicitly
mark it READ WRITE to override the default datanode behaviour.

Per report by Virendra Kumar

src/bin/pg_dump/pg_dump.c

index c842b0ea5ffc700e2e0702e47188094441cc83e5..f90b5d0a66a4f34932c6f08949ea579b4b522ca9 100644 (file)
@@ -1120,17 +1120,13 @@ setup_connection(Archive *AH, const char *dumpencoding,
                        ExecuteSqlStatement(AH,
                                                                "SET TRANSACTION ISOLATION LEVEL "
                                                                "SERIALIZABLE, "
-#ifndef XCP
-                                                               "READ ONLY, "
-#endif
+                                                               "READ WRITE, "
                                                                "DEFERRABLE");
                else
                        ExecuteSqlStatement(AH,
                                                                "SET TRANSACTION ISOLATION LEVEL "
-                                                               "REPEATABLE READ"
-#ifndef XCP
-                                                               ", READ ONLY"
-#endif
+                                                               "REPEATABLE READ,"
+                                                               "READ WRITE"
                                                                );
        }
        else