-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add support for SKIP LOCKED and NOWAIT #5249
Comments
The use case you describe is addressed by the messaging feature https://vitess.io/docs/reference/messaging/. But maybe |
We definitely have use cases where we would like to use @kocoten1992 Messaging works awesome, I highly recommend it. |
If I understand messaging correctly, this is a bit different. Messaging is a pub/sub, but |
I haven't tried it yet, but I am hoping that this PR is allowing it through now. #5336 |
it does not; this is still a TODO |
We may be interested by this for unsharded keyspace too. |
Reopening since it was only fixed on GitHub's fork, but it still needs to be upstreamed here in Vitess. |
Feature Description
Add suport for new feature skip locked and no wait in mysql 8, https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html
Use Case(s)
Skip locked especially useful in building a queue system (like RabbitMQ or AWS SQS - but better).
Let me much elaborate on the idea and how it work.
Imagine we have a tasks table and each row is a task need to be done, eg:
The table is a rip off of real table (but you get the idea), in table above field
executor
is important, when task already registered to a executor, other executors will not get that tasks anymore.And we have like 100 executors to get each row and execute the task, but when multiple executors try query, it is possible multiple executors might get a single task is available and try to register itself to do that task (concurrency issue).
The solution in this case is select for update, example:
When executor A try select for update on a single row of task, other executors (B, C...) try to query will get hanged up until executor A either commit or rollback, which is working and it good enough, but with skip locked, this pattern can do better (we don't have to wait for executor A to finish it's transaction)
Example:
It would achieve better concurency control in this case (noted only work in
READ COMMITED
mode, https://www.percona.com/blog/2012/08/28/differences-between-read-committed-and-repeatable-read-transaction-isolation-levels/)Currently vitess support select for update, it mostly good enough, but it will be greate if we having
skip locked
altogether.The text was updated successfully, but these errors were encountered: