mvcc/backend: restore original bolt db options after defrag
Problem: Defrag was implemented before custom bolt options were added. Currently defrag doesn't restore backend options. For example BackendFreelistType will be unset after defrag. Solution: save bolt db options and use them in defrag.
This commit is contained in:
@ -120,7 +120,16 @@ func TestBackendBatchIntervalCommit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBackendDefrag(t *testing.T) {
|
||||
b, tmpPath := NewDefaultTmpBackend()
|
||||
bcfg := DefaultBackendConfig()
|
||||
// Make sure we change BackendFreelistType
|
||||
// The goal is to verify that we restore config option after defrag.
|
||||
if bcfg.BackendFreelistType == bolt.FreelistMapType {
|
||||
bcfg.BackendFreelistType = bolt.FreelistArrayType
|
||||
} else {
|
||||
bcfg.BackendFreelistType = bolt.FreelistMapType
|
||||
}
|
||||
|
||||
b, tmpPath := NewTmpBackendFromCfg(bcfg)
|
||||
defer cleanup(b, tmpPath)
|
||||
|
||||
tx := b.BatchTx()
|
||||
@ -167,6 +176,10 @@ func TestBackendDefrag(t *testing.T) {
|
||||
t.Errorf("new size = %v, want < %d", nsize, size)
|
||||
}
|
||||
|
||||
if b.db.FreelistType != bcfg.BackendFreelistType {
|
||||
t.Errorf("db FreelistType = [%v], want [%v]", b.db.FreelistType, bcfg.BackendFreelistType)
|
||||
}
|
||||
|
||||
// try put more keys after shrink.
|
||||
tx = b.BatchTx()
|
||||
tx.Lock()
|
||||
|
Reference in New Issue
Block a user