-
Notifications
You must be signed in to change notification settings - Fork 409
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 sys_pgcon for long-term advisory locks #8320
Conversation
edb/server/protocol/ai_ext.py
Outdated
await pgconn.sql_execute(b"ROLLBACK TO SAVEPOINT " + sp) | ||
async with tenant.use_sys_pgcon() as syscon: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the try-lock for?
And couldn't it get taken by another connection after the ROLLBACK but before the lock?
Is that a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the try-lock for?
It checks if the lock is being held by another worker (through sys_pgcon). We cannot acquire this lock directly in sys_pgcon because, say if another worker is already holding this lock through sys_pgcon, re-acquiring the lock will not block (or fail with the try_* method) from the same sys_pgcon session.
And couldn't it get taken by another connection after the ROLLBACK but before the lock?
That's guaranteed not to happen by the outter/first lock, unless other code misused the same advisory lock ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I understand.
Probably could use some more comments, because the protocol here is subtle.
(Or are you changing the protocol per @mmastrac's comments?)
* Fixes the issue of advisory locks getting leaked back to the connection pool. * Fixes the `test_ext_ai_indexing_*` failures in CI.
* Fixes the issue of advisory locks getting leaked back to the connection pool. * Fixes the `test_ext_ai_indexing_*` failures in CI.
* Fixes the issue of advisory locks getting leaked back to the connection pool. * Fixes the `test_ext_ai_indexing_*` failures in CI.
test_ext_ai_indexing_*
failures in CI.Refs #7183, sample run