-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Loosen pessimistic transactions: skip acquiring locks for some statements #36579
Labels
type/enhancement
The issue or PR belongs to an enhancement.
Comments
This was referenced Jul 26, 2022
You mean skip the pessimistic lock for insert statement? For insert, we can try something like: optimistic first, and turn to pessimistic on conflict. |
Yes, it changes the semantics, so we leave the choice to users and do not change the default behavior. |
Get it! |
4 tasks
ti-chi-bot
pushed a commit
that referenced
this issue
Aug 17, 2022
ti-chi-bot
added a commit
to tikv/tikv
that referenced
this issue
Aug 25, 2022
close #13128, ref pingcap/tidb#36579 Signed-off-by: ekexium <eke@fastmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
TonsnakeLin
pushed a commit
to TonsnakeLin/tikv
that referenced
this issue
Aug 26, 2022
close tikv#13128, ref pingcap/tidb#36579 Signed-off-by: ekexium <eke@fastmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
TonsnakeLin
pushed a commit
to TonsnakeLin/tikv
that referenced
this issue
Aug 29, 2022
close tikv#13128, ref pingcap/tidb#36579 Signed-off-by: ekexium <eke@fastmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io> Signed-off-by: TonsnakeLin <lpbgytong@163.com>
fengou1
pushed a commit
to fengou1/tikv
that referenced
this issue
Aug 30, 2022
close tikv#13128, ref pingcap/tidb#36579 Signed-off-by: ekexium <eke@fastmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io> Signed-off-by: fengou1 <feng.ou@pingcap.com>
13 tasks
ti-chi-bot
pushed a commit
that referenced
this issue
Sep 1, 2022
12 tasks
3pointer
pushed a commit
to 3pointer/tikv
that referenced
this issue
Sep 6, 2022
close tikv#13128, ref pingcap/tidb#36579 Signed-off-by: ekexium <eke@fastmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io> Signed-off-by: 3pointer <luancheng@pingcap.com>
ti-chi-bot
pushed a commit
that referenced
this issue
Sep 6, 2022
12 tasks
ti-chi-bot
pushed a commit
that referenced
this issue
Sep 15, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Enhancement
Pessimistic transactions acquire locks for all DMLs. We can selectively skip some locking for better performance, at the cost of a probably lower success rate. Namely support a transaction behavior somewhere between current optimistic and pessimistic transactions.
Example
Consider the workload: there is a table
t
on which you only do simple INSERT and SELECT. The INSERTs and SELECTs are performed in a transaction that will modify other tables where a pessimistic transaction is preferred. There may be multiple threads running the same workload.You know you don't have to lock when inserting into
t
because if a conflicting concurrent insert happens, at most 1 transaction will succeed, while others will fail because of "duplicate key" errors. Skipping the lock of INSERT here and postponing the constraint check (namely the existence check) and conflict check to the prewrite phase can save you some requests for locking. The only downside is that a transaction won't know its INSERT failed until commit (previously it knows at the execution of the INSERT statement).How
Pessimistic locks basically serve 2 purposes:
Constraint check can be performed in prewrite as well. And we can perform a write conflict check just like in optimistic transactions for those keys that skipped acquiring pessimistic locks.
The text was updated successfully, but these errors were encountered: