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

Conversation

MasahikoSawada
Copy link
Contributor

In lock_access_share() function, before acquiring an AccessShareLock on the target table, concurrent DDL commands are terminated unconditionally. However, there is a window between this termination and the actual "LOCK TABLE ... IN ACCESS SHARE MODE" operation, allowing other DDL commands to run on the target table. If the LOCK TABLE failed due to a lock conflict, the transaction was rolled back and retried to execute LOCK TABLE, but the LOCK TABLE command could not be executed again as the transaction had already closed.

This commit fixes the issue by using SAVEPOINT and ROLLBACK TO SAVEPOINT so that we can retry to take a lock in the same top transaction.

Issue #383

In lock_access_share() function, before acquiring an AccessShareLock
on the target table, concurrent DDL commands are terminated
unconditionally. However, there is a window between this termination
and the actual "LOCK TABLE ... IN ACCESS SHARE MODE" operation,
allowing other DDL commands to run on the target table. If the LOCK
TABLE failed due to a lock conflict, the transaction was rolled back
and retried to execute LOCK TABLE, but the LOCK TABLE command could
not be executed again as the transaction had already closed.

This commit fixes the issue by using SAVEPOINT and ROLLBACK TO
SAVEPOINT so that we can retry to take a lock in the same top
transaction.

Issue reorg#383
Copy link
Collaborator

@za-arthur za-arthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!. It looks reasonable to me.

@MasahikoSawada MasahikoSawada merged commit f89c261 into reorg:master May 21, 2024
10 checks passed
@MasahikoSawada
Copy link
Contributor Author

Thank you for reviewing the change! Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants