From b29183aef941ef84de63231adc0fa464dd36214a Mon Sep 17 00:00:00 2001 From: sumeerbhola Date: Fri, 25 Feb 2022 19:50:27 -0500 Subject: [PATCH] db: produce the FlushEnd event after installing readState This helps unit tests that use the callback to trigger a read using an iterator with IterOptions.OnlyReadGuaranteedDurable. Informs https://github.com/cockroachdb/cockroach/issues/77046 --- compaction.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compaction.go b/compaction.go index dfc6d6c731..8648a1a5c7 100644 --- a/compaction.go +++ b/compaction.go @@ -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) @@ -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 */)