Skip to content

Commit bd84902

Browse files
committed
fix
1 parent 2d3dfd7 commit bd84902

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎pkg/store/cached_store.go‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,11 @@ func (cs *CachedStore) PruneBlocks(ctx context.Context, height uint64) error {
255255
// the write falls back to synchronous execution on the underlying store.
256256
func (cs *CachedStore) SetMetadata(ctx context.Context, key string, value []byte) error {
257257
cs.stopMu.RLock()
258+
defer cs.stopMu.RUnlock()
259+
258260
if cs.stopped {
259-
cs.stopMu.RUnlock()
260261
return cs.Store.SetMetadata(ctx, key, value)
261262
}
262-
cs.stopMu.RUnlock()
263-
264263
valueCopy := append([]byte(nil), value...)
265264
cs.writeCh <- asyncWriteOp{key: key, value: valueCopy}
266265
return nil
@@ -270,12 +269,11 @@ func (cs *CachedStore) SetMetadata(ctx context.Context, key string, value []byte
270269
// stopped, the delete falls back to synchronous execution.
271270
func (cs *CachedStore) DeleteMetadata(ctx context.Context, key string) error {
272271
cs.stopMu.RLock()
272+
defer cs.stopMu.RUnlock()
273+
273274
if cs.stopped {
274-
cs.stopMu.RUnlock()
275275
return cs.Store.DeleteMetadata(ctx, key)
276276
}
277-
cs.stopMu.RUnlock()
278-
279277
cs.writeCh <- asyncWriteOp{key: key, isDelete: true}
280278
return nil
281279
}

0 commit comments

Comments
 (0)