|
|
@@ -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"))
|