Browse Source

Merge pull request #9446 from gyuho/ttt

mvcc/backend: defrag to block concurrent read requests while resetting tx
Gyuho Lee 7 years ago
parent
commit
576a2ca501
1 changed files with 6 additions and 1 deletions
  1. 6 1
      mvcc/backend/backend.go

+ 6 - 1
mvcc/backend/backend.go

@@ -304,7 +304,12 @@ func (b *backend) defrag() error {
 	b.mu.Lock()
 	defer b.mu.Unlock()
 
-	b.batchTx.commit(true)
+	// block concurrent read requests while resetting tx
+	b.readTx.mu.Lock()
+	defer b.readTx.mu.Unlock()
+
+	b.batchTx.unsafeCommit(true)
+
 	b.batchTx.tx = nil
 
 	tmpdb, err := bolt.Open(b.db.Path()+".tmp", 0600, boltOpenOptions)