Skip to content

Commit

Permalink
create event do not need prevkv range
Browse files Browse the repository at this point in the history
  • Loading branch information
leoyang.yl committed Mar 2, 2021
1 parent 102c198 commit d70f35f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/etcdserver/api/v3rpc/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func (sws *serverWatchStream) sendLoop() {
sws.mu.RUnlock()
for i := range evs {
events[i] = &evs[i]
if needPrevKV {
if needPrevKV && !IsCreateEvent(evs[i]) {
opt := mvcc.RangeOptions{Rev: evs[i].Kv.ModRevision - 1}
r, err := sws.watchable.Range(context.TODO(), evs[i].Kv.Key, nil, opt)
if err == nil && len(r.KVs) != 0 {
Expand Down Expand Up @@ -501,6 +501,10 @@ func (sws *serverWatchStream) sendLoop() {
}
}

func IsCreateEvent(e mvccpb.Event) bool {
return e.Type == mvccpb.PUT && e.Kv.CreateRevision == e.Kv.ModRevision
}

func sendFragments(
wr *pb.WatchResponse,
maxRequestBytes int,
Expand Down

0 comments on commit d70f35f

Please sign in to comment.