-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Take ACCESS EXCLUSIVE LOCK carefully #8
Conversation
Try to get the lock in infinite loop with timeouts. This allows to not stuck lock queue for readers if pg_repack cannot take the lock fast enough. Links: https://adjustcom.atlassian.net/browse/PAD-234
Would it perhaps make sense to first acquire an This way a long-running |
@nick-adjust I think I understand what you propose. But what problem will it solve? I think the current PR also won't make readers and writers wait unnecessary. And the current problem is that long running query blocks If we get PS: Actually |
This reverts commit eefdf6d.
I mean a case where we have a long-running MERGE and we're trying to acquire an ACCESS EXCLUSIVE lock right away: we keep it for 1s and release it, making every single read query that comes after use wait for 1s. This can be eliminated by first trying to acquire an EXCLUSIVE lock, which won't block readers at all, but will conflict with writers. So the effect is:
I hope above points make sense. Otherwise questions are welcome. Also I don't insist on this being implemented in the PR, but this is something that is definitely worth keeping in mind and its worth observing the kpi-service response times once this patch is in production. |
Thanks for the clarification! Indeed it makes sense to call EXCLUSIVE first. There is a problem with implementing it because It can take longer time to implement than fixing the initial issue because it will be necessary to consider |
We use `lock_exclusive()` to take an exclusive lock. It tries to get the lock in a short time.
I pushed different commit. Now |
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.
Looks good to me.
Thank you!
I agree with @nick-adjust that we should try to get Exclusive lock first, then escalate afterwards. |
I updated the second link which was wrong. |
I'll merge this and create separate PR for escalating EXCLUSIVE lock. |
Try to get the lock in infinite loop with timeouts. This allows
to not stuck lock queue for readers if pg_repack cannot take the
lock fast enough.
Links: