Explorar o código

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.
Xiang Li %!s(int64=10) %!d(string=hai) anos
pai
achega
ae5161382b
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      storage/watchable_store.go

+ 1 - 1
storage/watchable_store.go

@@ -324,7 +324,6 @@ func (s *watchableStore) syncWatchers() {
 	tx := s.store.b.BatchTx()
 	tx := s.store.b.BatchTx()
 	tx.Lock()
 	tx.Lock()
 	ks, vs := tx.UnsafeRange(keyBucketName, minBytes, maxBytes, 0)
 	ks, vs := tx.UnsafeRange(keyBucketName, minBytes, maxBytes, 0)
-	tx.Unlock()
 
 
 	evs := []storagepb.Event{}
 	evs := []storagepb.Event{}
 
 
@@ -351,6 +350,7 @@ func (s *watchableStore) syncWatchers() {
 
 
 		evs = append(evs, ev)
 		evs = append(evs, ev)
 	}
 	}
+	tx.Unlock()
 
 
 	for w, es := range newWatcherToEventMap(s.unsynced, evs) {
 	for w, es := range newWatcherToEventMap(s.unsynced, evs) {
 		select {
 		select {