mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-05 08:10:50 +00:00
Merge pull request #839 from molecula/rbf-fix-checkpoint
Remove tx before issuing checkpoint.
This commit is contained in:
commit
343c446b7e
2 changed files with 17 additions and 6 deletions
|
|
@ -800,6 +800,8 @@ func (db *DB) removeTx(tx *Tx) error {
|
|||
db.mu.Lock()
|
||||
defer db.mu.Unlock()
|
||||
|
||||
delete(tx.db.txs, tx)
|
||||
|
||||
// Write pages from WAL to DB.
|
||||
// TODO(bbj): Move this to an async goroutine.
|
||||
if tx.writable {
|
||||
|
|
@ -808,8 +810,6 @@ func (db *DB) removeTx(tx *Tx) error {
|
|||
}
|
||||
}
|
||||
|
||||
delete(tx.db.txs, tx)
|
||||
|
||||
// Disassociate from db.
|
||||
tx.db = nil
|
||||
|
||||
|
|
|
|||
|
|
@ -92,14 +92,25 @@ func TestDB_Recovery(t *testing.T) {
|
|||
}
|
||||
|
||||
// Add one additional bit in a second transaction.
|
||||
if tx, err := db.Begin(true); err != nil {
|
||||
tx0, err := db.Begin(true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := tx.Add("x", uint64(len(a))); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if err := tx.Commit(); err != nil {
|
||||
} else if _, err := tx0.Add("x", uint64(len(a))); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Start a read-only transaction so the write tx does not checkpoint the WAL.
|
||||
tx1, err := db.Begin(false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Commit write transaction.
|
||||
if err := tx0.Commit(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx1.Rollback()
|
||||
|
||||
// Close database & truncate WAL to remove commit page & bitmap data page.
|
||||
segment := db.ActiveWALSegment()
|
||||
if err := db.Close(); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue