From 900bb8369bd3e28d14e67f017325e1109a12418c Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Fri, 18 Aug 2017 15:13:20 +0900 Subject: [PATCH] Reset the transcation state before exiting from lock_exclusive. Previously we exited from lock_exclusive() while opening the transaction that started at beggning if --no-kill-backend option is specified. This caused that DROP INDEX CONCURRENTLY fails because it cannot be executed within a user transaction block. Fixed issue #129. --- bin/pg_repack.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index 0316d98..9a62a47 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -1780,7 +1780,12 @@ lock_exclusive(PGconn *conn, const char *relid, const char *lock_query, bool sta { elog(WARNING, "timed out, do not cancel conflicting backends"); ret = false; - pgut_rollback(conn); + + /* Before exit the loop reset the transaction */ + if (start_xact) + pgut_rollback(conn); + else + pgut_command(conn, "ROLLBACK TO SAVEPOINT repack_sp1", 0, NULL); break; } else