mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-09 04:17:51 +00:00
move some locks, nbd
This commit is contained in:
parent
1fd872b126
commit
0799862266
2 changed files with 7 additions and 3 deletions
|
|
@ -380,6 +380,9 @@ func (db *DB) checkpoint() (err error) {
|
|||
|
||||
db.afterCurrentTx(func() {
|
||||
defer db.rwmu.Unlock()
|
||||
db.baseWALID = readMetaWALID(db.data)
|
||||
db.mu.Unlock()
|
||||
defer db.mu.Lock()
|
||||
|
||||
if err = db.walFile.Truncate(0); err != nil {
|
||||
db.logger.Errorf("truncate wal file: %w", err)
|
||||
|
|
@ -389,7 +392,6 @@ func (db *DB) checkpoint() (err error) {
|
|||
db.logger.Errorf("seek wal file: %w", err)
|
||||
}
|
||||
|
||||
db.baseWALID = readMetaWALID(db.data)
|
||||
})
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -102,8 +102,6 @@ func (tx *Tx) Commit() error {
|
|||
|
||||
// If any pages have been written, ensure we write a new meta page with
|
||||
// the commit flag to mark the end of the transaction.
|
||||
tx.db.mu.Lock()
|
||||
defer tx.db.mu.Unlock()
|
||||
if tx.dirty() {
|
||||
if err := tx.flush(); err != nil {
|
||||
return err
|
||||
|
|
@ -120,11 +118,15 @@ func (tx *Tx) Commit() error {
|
|||
// the lock, because we need removeTx to grab the lock to
|
||||
// work, but if it wants to checkpoint, it wants to be able to return
|
||||
// to us here and still be holding the lock.
|
||||
tx.db.mu.Lock()
|
||||
tx.db.rootRecords = tx.rootRecords
|
||||
tx.db.pageMap = tx.pageMap
|
||||
tx.db.walPageN = tx.walPageN
|
||||
tx.db.mu.Unlock()
|
||||
}
|
||||
|
||||
tx.db.mu.Lock()
|
||||
defer tx.db.mu.Unlock()
|
||||
// Disconnect transaction from DB.
|
||||
return tx.db.removeTx(tx)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue