Skip to content

Commit

Permalink
server: write pebble log messages to storage channel
Browse files Browse the repository at this point in the history
Previously, when setting up the server, the pebble engine would be
initialized with Pebble's default logger. The reason for this is that
the pebble initialization code calls `EnsureDefaults` on the
configuration options _before_ checking if the `options.Logger` is
nil/unset. At that point, it will never be unset, as `EnsureDefaults`
will set the logger to `pebble.DefaultLogger` if it was not previously
set.

This change overwrites the pebble logger if its found to be the
`DefaultLogger`. We never want to use pebble's `DefaultLogger` in CRDB
as that would mean pebble would use the standard library `log`
package, making every message emitted by Pebble to be treated as
`INFO` level messages, regardless of severity (including `log.Fatal`
calls).

Related to #83079.

Fixes #72683.
Fixes #90483.

Release note: None.
  • Loading branch information
renatolabs committed Oct 21, 2022
1 parent cfc0dbc commit 3cae346
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/storage/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,11 @@ func NewPebble(ctx context.Context, cfg PebbleConfig) (p *Pebble, err error) {
storeIDContainer := &base.StoreIDContainer{}
logCtx = logtags.AddTag(logCtx, "s", storeIDContainer)

if cfg.Opts.Logger == nil {
// If no logger was passed, the previous call to `EnsureDefaults` on
// `cfg.Opts` will set the logger to pebble's `DefaultLogger`. In
// crdb, we want pebble-related logs to go to the storage channel,
// so we update the logger here accordingly.
if cfg.Opts.Logger == nil || cfg.Opts.Logger == pebble.DefaultLogger {
cfg.Opts.Logger = pebbleLogger{
ctx: logCtx,
depth: 1,
Expand Down

0 comments on commit 3cae346

Please sign in to comment.