Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use savepoints when retrying to take AccessShareLock. #401

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions bin/pg_repack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,8 @@ kill_ddl(PGconn *conn, Oid relid, bool terminate)
/*
* Try to acquire an ACCESS SHARE table lock, avoiding deadlocks and long
* waits by killing off other sessions which may be stuck trying to obtain
* an ACCESS EXCLUSIVE lock.
* an ACCESS EXCLUSIVE lock. This function assumes that the transaction
* on "conn" already started.
*
* Arguments:
*
Expand All @@ -1777,6 +1778,8 @@ lock_access_share(PGconn *conn, Oid relid, const char *target_name)
PGresult *res;
int wait_msec;

pgut_command(conn, "SAVEPOINT repack_sp1", 0, NULL);

duration = time(NULL) - start;

/* Cancel queries unconditionally, i.e. don't bother waiting
Expand Down Expand Up @@ -1810,7 +1813,7 @@ lock_access_share(PGconn *conn, Oid relid, const char *target_name)
{
/* retry if lock conflicted */
CLEARPGRES(res);
pgut_rollback(conn);
pgut_command(conn, "ROLLBACK TO SAVEPOINT repack_sp1", 0, NULL);
continue;
}
else
Expand Down
Loading