-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
checkIntervals
will not validate correctly in certain nested txn scenarios
#16380
Comments
It's real issue, thanks for reporting it. Please raise a PR to fix it, the change should be as simple as below,
|
I think the puts should only be checked after all deletes have been added to I suggest the following changes:
|
You are right.
|
Sure, I'll take on this issue. |
Anyway, we should clearly define & clarify the expected behaviour firstly. |
I'll try to define the expected behaviour: We divide puts/dels into two class:
The constraints are:
For (2, 3) alternatively, together they can be described as: A
|
The issue actually only lies in constraint 3. The most straightforward way to check this is to enumerate for each two transactions, but it's indeed not very efficient. Do you have any alternative suggestions? @ahrtr |
Bug report criteria
What happened?
In
checkIntervals
there's seems to be bug in checking nested txns. In the following loop it check sub txn request and append the deletes todels
at the end.etcd/server/etcdserver/api/v3rpc/key.go
Lines 208 to 245 in 25315dd
Consider the following senerio(assume all requests are in the success branch): If a txn
S
contains two sub txnA
andB
.A
contains a put,B
contains a delete, and the put overlaps with the delete. ThenS[A(put), B(del)]
will return a ok butS[B(del), A(put)
will return an error.The reason this inconsistency exist is that the sub txn requests are checked in a specific order, and append the delete to
dels
in this order. And the put checksdels
for overlapping. So if the put is checked before the delete, it will not know that it overlaps with that delete.What did you expect to happen?
Both
S[A(put), B(del)]
andS[B(del), A(put)
should return an error. The deletes should be append todels
first before check the intersection of puts.How can we reproduce it (as minimally and precisely as possible)?
It should be reproduced by the following code
Anything else we need to know?
No response
Etcd version (please run commands below)
The latest
main
branchEtcd configuration (command line flags or environment variables)
paste your configuration here
Etcd debug information (please run commands below, feel free to obfuscate the IP address or FQDN in the output)
Relevant log output
No response
The text was updated successfully, but these errors were encountered: