Skip to content

Commit

Permalink
db: produce the FlushEnd event after installing readState
Browse files Browse the repository at this point in the history
This helps unit tests that use the callback to trigger a
read using an iterator with IterOptions.OnlyReadGuaranteedDurable.

Informs cockroachdb/cockroach#77046
  • Loading branch information
sumeerbhola committed Feb 27, 2022
1 parent cb84847 commit b29183a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions compaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -1451,9 +1451,6 @@ func (d *DB) flush1() error {
d.mu.versions.incrementCompactions(c.kind)
d.mu.versions.incrementCompactionBytes(-c.bytesWritten)

info.TotalDuration = d.timeNow().Sub(startTime)
d.opts.EventListener.FlushEnd(info)

// Refresh bytes flushed count.
atomic.StoreUint64(&d.atomic.bytesFlushed, 0)

Expand All @@ -1468,6 +1465,11 @@ func (d *DB) flush1() error {
// TODO(jackson): Remove this when range keys are persisted to sstables.
err = d.applyFlushedRangeKeys(flushed)
}
// Signal FlushEnd after installing the new readState. This helps for unit
// tests that use the callback to trigger a read using an iterator with
// IterOptions.OnlyReadGuaranteedDurable.
info.TotalDuration = d.timeNow().Sub(startTime)
d.opts.EventListener.FlushEnd(info)

d.deleteObsoleteFiles(jobID, false /* waitForOngoing */)

Expand Down

0 comments on commit b29183a

Please sign in to comment.