Properly detect compactable heads

The fullness of the wrong head was being tracked, causing wrong
lists of compactable heads.
pull/5805/head
Fabian Reinartz 7 years ago
parent 15baaa5677
commit fa04455cd7

@ -360,8 +360,11 @@ func (db *DB) completedHeads() (r []headBlock) {
// Add the 2nd last head if the last head is more than 50% filled. // Add the 2nd last head if the last head is more than 50% filled.
// Compacting it early allows us to free its memory before allocating // Compacting it early allows us to free its memory before allocating
// more for the next block and thus reduces spikes. // more for the next block and thus reduces spikes.
if h2 := db.heads[len(db.heads)-2]; headFullness(h2) >= 0.5 && h2.ActiveWriters() == 0 { h0 := db.heads[len(db.heads)-1]
r = append(r, h2) h1 := db.heads[len(db.heads)-2]
if headFullness(h0) >= 0.5 && h1.ActiveWriters() == 0 {
r = append(r, h1)
} }
return r return r
} }

Loading…
Cancel
Save