diff --git a/server/etcdserver/api/v3rpc/watch.go b/server/etcdserver/api/v3rpc/watch.go index 4531dbe60bf..c56ec4b26e7 100644 --- a/server/etcdserver/api/v3rpc/watch.go +++ b/server/etcdserver/api/v3rpc/watch.go @@ -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 { @@ -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,