Skip to content

Commit d649536

Browse files
committed
fix: ensure range requests in txn are executed on all cluster members
Fix data inconsistency issue #18667 where specifying a revision for a range request in a transaction may cause data inconsistency across cluster members. The removeNeedlessRangeReqs function was incorrectly removing range requests from txn operations on some cluster members, causing write operations to be executed on some members while failing on others.
1 parent 23085b4 commit d649536

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

server/etcdserver/apply/apply.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ func Apply(lg *zap.Logger, e *raftpb.Entry, uberApply UberApplier, w wait.Wait,
3939

4040
needResult := w.IsRegistered(id)
4141
if needResult || !noSideEffect(&raftReq) {
42-
if !needResult && raftReq.Txn != nil {
43-
removeNeedlessRangeReqs(raftReq.Txn)
44-
}
4542
return uberApply.Apply(&raftReq, shouldApplyV3), id
4643
}
4744
return nil, id
@@ -50,21 +47,3 @@ func Apply(lg *zap.Logger, e *raftpb.Entry, uberApply UberApplier, w wait.Wait,
5047
func noSideEffect(r *pb.InternalRaftRequest) bool {
5148
return r.Range != nil || r.AuthUserGet != nil || r.AuthRoleGet != nil || r.AuthStatus != nil
5249
}
53-
54-
func removeNeedlessRangeReqs(txn *pb.TxnRequest) {
55-
f := func(ops []*pb.RequestOp) []*pb.RequestOp {
56-
j := 0
57-
for i := 0; i < len(ops); i++ {
58-
if _, ok := ops[i].Request.(*pb.RequestOp_RequestRange); ok {
59-
continue
60-
}
61-
ops[j] = ops[i]
62-
j++
63-
}
64-
65-
return ops[:j]
66-
}
67-
68-
txn.Success = f(txn.Success)
69-
txn.Failure = f(txn.Failure)
70-
}

0 commit comments

Comments
 (0)