From dcce8e43e927f78e8bc91692cb5301f929869b05 Mon Sep 17 00:00:00 2001 From: Edwina Lu Date: Fri, 15 Apr 2016 14:34:41 -0700 Subject: [PATCH] grab exclusive lock before dropping table --- bin/pg_repack.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index dcd4340..e67ce05 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -1392,6 +1392,14 @@ repack_one_table(repack_table *table, const char *orderby) elog(DEBUG2, "---- drop ----"); command("BEGIN ISOLATION LEVEL READ COMMITTED", 0, NULL); + if (!(lock_exclusive(connection, utoa(table->target_oid, buffer), + table->lock_table, FALSE))) + { + elog(WARNING, "lock_exclusive() failed in connection for %s", + table->target_name); + goto cleanup; + } + params[1] = utoa(temp_obj_num, indexbuffer); command("SELECT repack.repack_drop($1, $2)", 2, params); command("COMMIT", 0, NULL);