From ae5161382bbf99097eaadd15017d1aaaf4ac79b3 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Tue, 2 Feb 2016 22:48:50 -0800 Subject: [PATCH] storage: release tx lock until finish using the readonly bytes The backend will return read only bytes that are only vaild while the tx is open. We should hold the lock until we get a full copy by unmarshal. --- storage/watchable_store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/watchable_store.go b/storage/watchable_store.go index fef796008..2f0a0578e 100644 --- a/storage/watchable_store.go +++ b/storage/watchable_store.go @@ -324,7 +324,6 @@ func (s *watchableStore) syncWatchers() { tx := s.store.b.BatchTx() tx.Lock() ks, vs := tx.UnsafeRange(keyBucketName, minBytes, maxBytes, 0) - tx.Unlock() evs := []storagepb.Event{} @@ -351,6 +350,7 @@ func (s *watchableStore) syncWatchers() { evs = append(evs, ev) } + tx.Unlock() for w, es := range newWatcherToEventMap(s.unsynced, evs) { select {