Skip to content

Commit

Permalink
fix(compact): close vlog after the compaction at L0 has completed (dg…
Browse files Browse the repository at this point in the history
…raph-io#1752)

Vlog needs to stay open while the compaction is being run. With the CompactL0OnClose option, it becomes necessary to close the vlog after all the compactions have been completed.
  • Loading branch information
NamanJain8 authored and fredcarle committed Aug 1, 2023
1 parent dac00fa commit 98b5135
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions db_test.go
Expand Up @@ -2635,3 +2635,32 @@ func TestCompactL0OnClose(t *testing.T) {
}
})
}

func TestCompactL0OnClose(t *testing.T) {
opt := getTestOptions("")
opt.CompactL0OnClose = true
opt.ValueThreshold = 1 // Every value goes to value log
opt.NumVersionsToKeep = 1
runBadgerTest(t, &opt, func(t *testing.T, db *DB) {
var keys [][]byte
val := make([]byte, 1<<12)
for i := 0; i < 10; i++ {
key := make([]byte, 40)
_, err := rand.Read(key)
require.NoError(t, err)
keys = append(keys, key)

err = db.Update(func(txn *Txn) error {
return txn.SetEntry(NewEntry(key, val))
})
require.NoError(t, err)
}

for _, key := range keys {
err := db.Update(func(txn *Txn) error {
return txn.SetEntry(NewEntry(key, val))
})
require.NoError(t, err)
}
})
}

0 comments on commit 98b5135

Please sign in to comment.