Skip to content

Commit

Permalink
Merge pull request etcd-io#7411 from heyitsanthony/mirror-batch
Browse files Browse the repository at this point in the history
etcdctl: correctly batch revisions in make-mirror
  • Loading branch information
Anthony Romano authored Mar 3, 2017
2 parents 9cc013f + ad45958 commit 42c9812
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions etcdctl/ctlv3/command/make_mirror_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 42c9812

Please sign in to comment.