From 3e912c3baa9dc70add71a034ce07a0cbd8c92702 Mon Sep 17 00:00:00 2001 From: William Choe Date: Thu, 26 Mar 2026 15:04:29 -0400 Subject: [PATCH] storage: override Pebble's ExitFunc to route through fatal logging Set pebble.Options.ExitFunc so that Pebble invariant violation exits (cache assertions, memtable checks, sstable reader checks) route through CockroachDB's log.Fatal path instead of calling os.Exit(1) directly. This gives visibility into why the process died via log lines, Sentry crash reports, and fatal exit marker files. Requires cockroachdb/pebble#5865. Co-Authored-By: roachdev-claude --- pkg/storage/pebble.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/storage/pebble.go b/pkg/storage/pebble.go index f7d19272eed3..425d29035d72 100644 --- a/pkg/storage/pebble.go +++ b/pkg/storage/pebble.go @@ -1209,6 +1209,17 @@ func newPebble(ctx context.Context, cfg engineConfig) (p *Pebble, err error) { } // Else, already have a LoggerAndTracer. This only occurs in unit tests. + // Override Pebble's exit function so that invariant violation exits + // route through CockroachDB's fatal logging. Without this, Pebble's + // direct os.Exit(1) calls (cache invariant checks, memtable + // assertions, etc.) bypass all logging, crash reporting, and marker + // file writing — the process just vanishes with no indication of why. + // + // Requires cockroachdb/pebble#5865. + cfg.opts.ExitFunc = func(code int) { + log.Storage.Fatalf(logCtx, "pebble: invariant violation (exit code %d)", code) + } + // Establish the emergency ballast if we can. If there's not sufficient // disk space, the ballast will be reestablished from Capacity when the // store's capacity is queried periodically.