Skip to content

Commit

Permalink
fix: Disable CompactL0OnClose by default (#1586)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza authored Nov 10, 2020
1 parent 6c07455 commit 8e4085b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ func TestForceCompactL0(t *testing.T) {
require.NoError(t, err)
defer removeDir(dir)

opts := getTestOptions(dir)
// This test relies on CompactL0OnClose
opts := getTestOptions(dir).WithCompactL0OnClose(true)
opts.ValueLogFileSize = 15 << 20
opts.managedTxns = true
db, err := Open(opts)
Expand Down
3 changes: 2 additions & 1 deletion merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ func TestGetMergeOperator(t *testing.T) {
require.NoError(t, err)
defer removeDir(dir)

opts := getTestOptions(dir)
// This test relies on CompactL0OnClose
opts := getTestOptions(dir).WithCompactL0OnClose(true)
db, err := Open(opts)
require.NoError(t, err)
mergeKey := []byte("foo")
Expand Down
7 changes: 3 additions & 4 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func DefaultOptions(path string) Options {
BlockSize: 4 * 1024,
SyncWrites: false,
NumVersionsToKeep: 1,
CompactL0OnClose: true,
CompactL0OnClose: false,
VerifyValueChecksum: false,
Compression: options.Snappy,
BlockCacheSize: 256 << 20,
Expand Down Expand Up @@ -425,10 +425,9 @@ func (opt Options) WithNumCompactors(val int) Options {
}

// WithCompactL0OnClose determines whether Level 0 should be compacted before closing the DB. This
// ensures that both reads and writes are efficient when the DB is opened later. CompactL0OnClose
// is set to true if KeepL0InMemory is set to true.
// ensures that both reads and writes are efficient when the DB is opened later.
//
// The default value of CompactL0OnClose is true.
// The default value of CompactL0OnClose is false.
func (opt Options) WithCompactL0OnClose(val bool) Options {
opt.CompactL0OnClose = val
return opt
Expand Down

0 comments on commit 8e4085b

Please sign in to comment.