Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compaction): copy over the file ID when building tables #1713

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions levels.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,34 +830,29 @@ func (s *levelsController) subcompact(it y.Iterator, kr keyRange, cd compactDef,
continue
}
numBuilds++
fileID := s.reserveFileID()
if err := inflightBuilders.Do(); err != nil {
// Can't return from here, until I decrRef all the tables that I built so far.
break
}
go func(builder *table.Builder) {
go func(builder *table.Builder, fileID uint64) {
var err error
defer inflightBuilders.Done(err)
defer builder.Close()

build := func(fileID uint64) (*table.Table, error) {
fname := table.NewFilename(fileID, s.kv.opt.Dir)
return table.CreateTable(fname, builder)
}

var tbl *table.Table
if s.kv.opt.InMemory {
tbl, err = table.OpenInMemoryTable(builder.Finish(), fileID, &bopts)
} else {
tbl, err = build(fileID)
fname := table.NewFilename(fileID, s.kv.opt.Dir)
tbl, err = table.CreateTable(fname, builder)
}

// If we couldn't build the table, return fast.
if err != nil {
return
}
res <- tbl
}(builder)
}(builder, s.reserveFileID())
}
s.kv.vlog.updateDiscardStats(discardStats)
s.kv.opt.Debugf("Discard stats: %v", discardStats)
Expand Down