Data inconsistency caused by TXN with a Range on a compacted revision #18652
-
I'm a new user of etcd,and I setup the etcd's cluster by docker on the same machine.
when I try a txn operation as below,data inconsistency happen.
because revision 45 had been compacted, so txn success operations will fail in the middle, key "fo" original value is "abc", so the txn do nothing on node1, but it put the value "foo" on node2 and node3!!! And "revision" is different too.(I try it many times, so node1's revision is 71, node2's and node3's revision is 81.) I just test it for learning. Is that test is illegal and not be allowed? Or is it a bug? Because the txn is failed, my expectation is nothing will be done by the txn. If it is impossible, at least "put fo foo" should apply to all nodes to keep consistently. But it isn't. On the other hand, I need some help to repair the inconsistent data. I restart the etcd cluster, but it doesn't work. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Thanks @davidhenrygao , and I reproduced this issue! How to reproduce this issue
The client will get a
Root causeetcd server removes range requests from the TXN for endpoints the client isn’t connected to. etcd/server/etcdserver/server.go Lines 1967 to 1971 in 2c97110 For example, if the client connects to member 1, then etcdserver removes the range request ( etcd/server/etcdserver/txn/txn.go Lines 431 to 441 in 2c97110 SolutionThe simplest solution is we don't remove range requests from TXN for any member. The side effect is that other endpoints (the client isn't connected to) will execute the unnecessary range operations. To resolve the side effect above, we don't execute the range requests on other endpoints that the client isn't connected to; instead etcdservers only verify them to ensure all endpoints always execute consistent validation. Impact
|
Beta Was this translation helpful? Give feedback.
Thanks @davidhenrygao , and I reproduced this issue!
How to reproduce this issue
for i in {1..20}; do ./etcdctl put k$i v$i; done
./etcdctl compact 21
./etcdctl txn --interactive
The client will get a
**etcdserver: mvcc: required revision has been compacted**
error../etcdctl get k2
against different endpoints, you will get different values,