Skip to content

Commit

Permalink
db: add DebugString method
Browse files Browse the repository at this point in the history
Add a `DB.DebugString()` method which can be used during debugging.
The meta test uses it to log the final state of the db (which after
reduction will be right after the problematic operation).
  • Loading branch information
RaduBerinde committed Feb 22, 2024
1 parent 2537487 commit 704018c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3082,3 +3082,10 @@ func (d *DB) checkVirtualBounds(m *fileMetadata) {
panic(err)
}
}

// DebugString returns a debugging string describing the LSM.
func (d *DB) DebugString() string {
d.mu.Lock()
defer d.mu.Unlock()
return d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
}
11 changes: 11 additions & 0 deletions metamorphic/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,17 @@ func RunOnce(t TestingT, runDir string, seed uint64, historyPath string, rOpts .
if err := Execute(m); err != nil {
fmt.Fprintf(os.Stderr, "Seed: %d\n", seed)
fmt.Fprintln(os.Stderr, err)
}

// If we have unclosed databases, print LSM details. This will be the case
// when we use --try-to-reduce.
for i, db := range m.dbs {
if db != nil {
fmt.Fprintf(os.Stderr, "\ndb%d:\n%s", i+1, db.DebugString())
}
}

if err != nil {
m.saveInMemoryData()
os.Exit(1)
}
Expand Down

0 comments on commit 704018c

Please sign in to comment.