Merge pull request #9446 from gyuho/ttt

mvcc/backend: defrag to block concurrent read requests while resetting tx
release-3.4
Gyuho Lee 2018-03-16 12:48:48 -07:00 committed by GitHub
commit 576a2ca501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

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