Skip to content

Commit

Permalink
levels: Cleanup builder resources on building an empty table (#1414)
Browse files Browse the repository at this point in the history
The compaction process can leak `*table.Builder` instances if the table built
is empty.

This used to be a big problem: before #1409 it would leak out the block
compression/encryption goroutines (that are all blocked on reading from the
`b.blockChan`, and because of that, it would leak the builder too.

Since #1409 this is now a simple question of correctness. Take it or leave it.
  • Loading branch information
damz authored Jul 13, 2020
1 parent 78f6e73 commit 8dd3fd9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions levels.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ nextTable:
return tbl, errors.Wrapf(err, "Unable to open table: %q", fd.Name())
}
if builder.Empty() {
// Cleanup builder resources:
builder.Finish()
builder.Close()
continue
}
numBuilds++
Expand Down

0 comments on commit 8dd3fd9

Please sign in to comment.