From fbc0fd5721c2059e1c681f3262bc804bcaa39587 Mon Sep 17 00:00:00 2001 From: Pavan Deolasee Date: Fri, 26 Oct 2018 15:54:27 +0530 Subject: [PATCH] Force READ WRITE transaction while running pg_rewind Since direct connections to a datanode by default use read-only transactions, we need to explicitly set transaction as read write so that temporary tables can be created and written to. Report and patch by Virendra Kumar. --- src/bin/pg_rewind/libpq_fetch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c index 89d7886fd1..0125ec1709 100644 --- a/src/bin/pg_rewind/libpq_fetch.c +++ b/src/bin/pg_rewind/libpq_fetch.c @@ -458,8 +458,11 @@ libpq_executeFileMap(filemap_t *map) /* * First create a temporary table, and load it with the blocks that we * need to fetch. + * + * Since Postgres-XL defaults to read-only transactions when connected to + * the datanodes directly, we must overwrite that explicitly. */ - sql = "CREATE TEMPORARY TABLE fetchchunks(path text, begin int8, len int4);"; + sql = "BEGIN TRANSACTION READ WRITE; CREATE TEMPORARY TABLE fetchchunks(path text, begin int8, len int4); COMMIT"; res = PQexec(conn, sql); if (PQresultStatus(res) != PGRES_COMMAND_OK) @@ -467,7 +470,7 @@ libpq_executeFileMap(filemap_t *map) PQresultErrorMessage(res)); PQclear(res); - sql = "COPY fetchchunks FROM STDIN"; + sql = "BEGIN TRANSACTION READ WRITE; COPY fetchchunks FROM STDIN; COMMIT"; res = PQexec(conn, sql); if (PQresultStatus(res) != PGRES_COPY_IN) -- 2.39.5