From ad45958841bcbde2e4c478dd7730556ac56cec75 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Thu, 2 Mar 2017 14:30:24 -0800 Subject: [PATCH] etcdctl: correctly batch revisions in make-mirror Fixes #7410 --- etcdctl/ctlv3/command/make_mirror_command.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/etcdctl/ctlv3/command/make_mirror_command.go b/etcdctl/ctlv3/command/make_mirror_command.go index 1101ab124a3..e333c9994b7 100644 --- a/etcdctl/ctlv3/command/make_mirror_command.go +++ b/etcdctl/ctlv3/command/make_mirror_command.go @@ -125,18 +125,19 @@ func makeMirror(ctx context.Context, c *clientv3.Client, dc *clientv3.Client) er return rpctypes.ErrCompacted } - var rev int64 + var lastRev int64 ops := []clientv3.Op{} for _, ev := range wr.Events { - nrev := ev.Kv.ModRevision - if rev != 0 && nrev > rev { + nextRev := ev.Kv.ModRevision + if lastRev != 0 && nextRev > lastRev { _, err := dc.Txn(ctx).Then(ops...).Commit() if err != nil { return err } ops = []clientv3.Op{} } + lastRev = nextRev switch ev.Type { case mvccpb.PUT: ops = append(ops, clientv3.OpPut(modifyPrefix(string(ev.Kv.Key)), string(ev.Kv.Value)))