Skip to content

Commit

Permalink
Execute the same validation for TXN
Browse files Browse the repository at this point in the history
This commit will ensure all members execute the same validation for TXN by not removing range requests from TXN.
Ref patch: ahrtr@76ac23f

Signed-off-by: ArkaSaha30 <[email protected]>
  • Loading branch information
ArkaSaha30 committed Oct 5, 2024
1 parent 7b429f9 commit d25513d
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions server/etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1967,9 +1967,6 @@ func (s *EtcdServer) applyEntryNormal(e *raftpb.Entry, shouldApplyV3 membership.

needResult := s.w.IsRegistered(id)
if needResult || !noSideEffect(&raftReq) {
if !needResult && raftReq.Txn != nil {
removeNeedlessRangeReqs(raftReq.Txn)
}
ar = s.applyInternalRaftRequest(&raftReq, shouldApplyV3)
}

Expand Down Expand Up @@ -2041,24 +2038,6 @@ func noSideEffect(r *pb.InternalRaftRequest) bool {
return r.Range != nil || r.AuthUserGet != nil || r.AuthRoleGet != nil || r.AuthStatus != nil
}

func removeNeedlessRangeReqs(txn *pb.TxnRequest) {
f := func(ops []*pb.RequestOp) []*pb.RequestOp {
j := 0
for i := 0; i < len(ops); i++ {
if _, ok := ops[i].Request.(*pb.RequestOp_RequestRange); ok {
continue
}
ops[j] = ops[i]
j++
}

return ops[:j]
}

txn.Success = f(txn.Success)
txn.Failure = f(txn.Failure)
}

// applyConfChange applies a ConfChange to the server. It is only
// invoked with a ConfChange that has already passed through Raft
func (s *EtcdServer) applyConfChange(cc raftpb.ConfChange, confState *raftpb.ConfState, shouldApplyV3 membership.ShouldApplyV3) (bool, error) {
Expand Down

0 comments on commit d25513d

Please sign in to comment.