mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #14340 from xakdwch/main
etcdctl: add --max-txn-ops flag to make-mirror command
This commit is contained in:
commit
ff6b85da83
@ -29,6 +29,7 @@ See [code changes](https://github.com/etcd-io/etcd/compare/v3.5.0...v3.6.0).
|
||||
- When print endpoint status, [show db size in use](https://github.com/etcd-io/etcd/pull/13639)
|
||||
- [Always print the raft_term in decimal](https://github.com/etcd-io/etcd/pull/13711) when displaying member list in json.
|
||||
- [Add one more field `storageVersion`](https://github.com/etcd-io/etcd/pull/13773) into the response of command `etcdctl endpoint status`.
|
||||
- Add [`--max-txn-ops`](https://github.com/etcd-io/etcd/pull/14340) flag to make-mirror command.
|
||||
|
||||
### etcdutl v3
|
||||
|
||||
|
@ -1466,6 +1466,8 @@ RPC: UserRevokeRole
|
||||
|
||||
- dest-insecure-transport -- Disable transport security for client connections
|
||||
|
||||
- max-txn-ops -- Maximum number of operations permitted in a transaction during syncing updates
|
||||
|
||||
#### Output
|
||||
|
||||
The approximate total number of keys transferred to the destination cluster, updated every 30 seconds.
|
||||
|
@ -33,6 +33,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultMaxTxnOps = uint(128)
|
||||
)
|
||||
|
||||
var (
|
||||
mminsecureTr bool
|
||||
mmcert string
|
||||
@ -44,6 +48,7 @@ var (
|
||||
mmpassword string
|
||||
mmnodestprefix bool
|
||||
mmrev int64
|
||||
mmmaxTxnOps uint
|
||||
)
|
||||
|
||||
// NewMakeMirrorCommand returns the cobra command for "makeMirror".
|
||||
@ -56,6 +61,7 @@ func NewMakeMirrorCommand() *cobra.Command {
|
||||
|
||||
c.Flags().StringVar(&mmprefix, "prefix", "", "Key-value prefix to mirror")
|
||||
c.Flags().Int64Var(&mmrev, "rev", 0, "Specify the kv revision to start to mirror")
|
||||
c.Flags().UintVar(&mmmaxTxnOps, "max-txn-ops", defaultMaxTxnOps, "Maximum number of operations permitted in a transaction during syncing updates.")
|
||||
c.Flags().StringVar(&mmdestprefix, "dest-prefix", "", "destination prefix to mirror a prefix to a different prefix in the destination cluster")
|
||||
c.Flags().BoolVar(&mmnodestprefix, "no-dest-prefix", false, "mirror key-values to the root of the destination cluster")
|
||||
c.Flags().StringVar(&mmcert, "dest-cert", "", "Identify secure client using this TLS certificate file for the destination cluster")
|
||||
@ -197,6 +203,15 @@ func makeMirror(ctx context.Context, c *clientv3.Client, dc *clientv3.Client) er
|
||||
ops = []clientv3.Op{}
|
||||
}
|
||||
lastRev = nextRev
|
||||
|
||||
if len(ops) == int(mmmaxTxnOps) {
|
||||
_, err := dc.Txn(ctx).Then(ops...).Commit()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ops = []clientv3.Op{}
|
||||
}
|
||||
|
||||
switch ev.Type {
|
||||
case mvccpb.PUT:
|
||||
ops = append(ops, clientv3.OpPut(modifyPrefix(string(ev.Kv.Key)), string(ev.Kv.Value)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user