Skip to content

Commit

Permalink
Merge pull request #7020 from heyitsanthony/etcdctl-migrate-warn
Browse files Browse the repository at this point in the history
etcdctl: warn when backend takes too long to open on migrate
  • Loading branch information
Anthony Romano authored Dec 16, 2016
2 parents 1095773 + e71ff36 commit d9e928d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion etcdctl/ctlv3/command/migrate_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit d9e928d

Please sign in to comment.