mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctl: warn when backend takes too long to open on migrate
This commit is contained in:
parent
52e3dc5eb9
commit
e71ff361a4
@ -100,8 +100,22 @@ func migrateCommandFunc(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
||||
func prepareBackend() backend.Backend {
|
||||
var be backend.Backend
|
||||
|
||||
bch := make(chan struct{})
|
||||
dbpath := path.Join(migrateDatadir, "member", "snap", "db")
|
||||
be := backend.New(dbpath, time.Second, 10000)
|
||||
go func() {
|
||||
defer close(bch)
|
||||
be = backend.New(dbpath, time.Second, 10000)
|
||||
|
||||
}()
|
||||
select {
|
||||
case <-bch:
|
||||
case <-time.After(time.Second):
|
||||
fmt.Fprintf(os.Stderr, "waiting for etcd to close and release its lock on %q\n", dbpath)
|
||||
<-bch
|
||||
}
|
||||
|
||||
tx := be.BatchTx()
|
||||
tx.Lock()
|
||||
tx.UnsafeCreateBucket([]byte("key"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user