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 L0/L1 stall test #1201

Merged
merged 2 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
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
9 changes: 3 additions & 6 deletions levels.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,9 @@ type levelsController struct {
kv *DB

cstatus compactStatus
}

var (
// This is for getting timings between stalls.
lastUnstalled time.Time
)
}

// revertToManifest checks that all necessary table files exist and removes all table files not
// referenced by the manifest. idMap is a set of table file id's that were read from the directory
Expand Down Expand Up @@ -929,7 +926,7 @@ func (s *levelsController) addLevel0Table(t *table.Table) error {
// Stall. Make sure all levels are healthy before we unstall.
var timeStart time.Time
{
s.elog.Printf("STALLED STALLED STALLED: %v\n", time.Since(lastUnstalled))
s.elog.Printf("STALLED STALLED STALLED: %v\n", time.Since(s.lastUnstalled))
s.cstatus.RLock()
for i := 0; i < s.kv.opt.MaxLevels; i++ {
s.elog.Printf("level=%d. Status=%s Size=%d\n",
Expand All @@ -956,7 +953,7 @@ func (s *levelsController) addLevel0Table(t *table.Table) error {
}
{
s.elog.Printf("UNSTALLED UNSTALLED UNSTALLED: %v\n", time.Since(timeStart))
lastUnstalled = time.Now()
s.lastUnstalled = time.Now()
}
}

Expand Down
20 changes: 4 additions & 16 deletions levels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func TestL1Stall(t *testing.T) {
db.lc.levels[1].totalSize = 100
go func() {
tab := createEmptyTable(db)
db.lc.addLevel0Table(tab)
require.NoError(t, db.lc.addLevel0Table(tab))
tab.DecrRef()
done <- true
}()
Expand Down Expand Up @@ -499,24 +499,12 @@ func createEmptyTable(db *DB) *table.Table {
b := table.NewTableBuilder(opts)
// Add one key so that we can open this table.
b.Add(y.KeyWithTs([]byte("foo"), 1), y.ValueStruct{}, 0)
fd, err := y.CreateSyncedFile(table.NewFilename(db.lc.reserveFileID(), db.opt.Dir), true)
if err != nil {
panic(err)
}

if _, err := fd.Write(b.Finish()); err != nil {
panic(err)
}
tab, err := table.OpenTable(fd, table.Options{})
// Open table in memory to avoid adding changes to manifest file.
tab, err := table.OpenInMemoryTable(b.Finish(), db.lc.reserveFileID(), &opts)
if err != nil {
panic(err)
}
// Add dummy entry to manifest file so that it doesn't complain during compaction.
if err := db.manifest.addChanges([]*pb.ManifestChange{
newCreateChange(tab.ID(), 0, 0, tab.CompressionType()),
}); err != nil {
panic(err)
}

return tab
}
Expand All @@ -537,7 +525,7 @@ func TestL0Stall(t *testing.T) {

go func() {
tab := createEmptyTable(db)
db.lc.addLevel0Table(tab)
require.NoError(t, db.lc.addLevel0Table(tab))
tab.DecrRef()
done <- true
}()
Expand Down