Skip to content

Commit

Permalink
storage: reorder EventListeners
Browse files Browse the repository at this point in the history
To be defensive, sequence the EventListener responsible for crashing the
process during a disk stall first, before the Pebble logging event listener.

Informs cockroachdb#94373.
Epic: None
Release note: None
  • Loading branch information
jbowens authored and nicktrav committed Feb 25, 2023
1 parent 7f22dc1 commit 075f846
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/storage/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -848,12 +848,19 @@ func NewPebble(ctx context.Context, cfg PebbleConfig) (p *Pebble, err error) {
storeIDPebbleLog: storeIDContainer,
closer: filesystemCloser,
}

// NB: The ordering of the event listeners passed to TeeEventListener is
// deliberate. The listener returned by makeMetricEtcEventListener is
// responsible for crashing the process if a DiskSlow event indicates the
// disk is stalled. While the logging subsystem should also be robust to
// stalls and crash the process if unable to write logs, there's less risk
// to sequencing the crashing listener first.
cfg.Opts.EventListener = pebble.TeeEventListener(
p.makeMetricEtcEventListener(ctx),
pebble.MakeLoggingEventListener(pebbleLogger{
ctx: logCtx,
depth: 2, // skip over the EventListener stack frame
}),
p.makeMetricEtcEventListener(ctx),
)
p.eventListener = &cfg.Opts.EventListener
p.wrappedIntentWriter = wrapIntentWriter(ctx, p)
Expand Down

0 comments on commit 075f846

Please sign in to comment.