Skip to content

Commit

Permalink
util/log: stop syncing writes excessively
Browse files Browse the repository at this point in the history
Release note (cli change): Previously, for certain log files
CockroachDB would both flush individual writes (i.e. propagate them
from within the `cockroach` process to the OS) and also synchronize
writes (i.e. ask the OS to confirm the log data was written to
disk). The per-write synchronization part was unnecessary and, in
fact, found to be possibly detrimental to performance and operating
cost, so it was removed. Meanwhile, the log data continues to be
flushed as previously, and CockroachDB also periodically (every 30s)
request synchronization, also as previously.

Release note (cli change): The parameter `sync-writes` for file sink
configurations has been removed. (This is not a backward-incompatible
change because the configuration feature is new in v21.1.)

Release note (cli change): The parameter `buffered-writes` for file
sink configurations has been added. It is set to `true` (writes are
buffered) by default; and set to `false` (i.e. avoid buffering and
flush every log entry) when the `auditable` flag is requested.
  • Loading branch information
knz committed Jan 14, 2021
1 parent b22e903 commit baf49d1
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 159 deletions.
11 changes: 6 additions & 5 deletions pkg/cli/log_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,22 @@ func TestSetupLogging(t *testing.T) {
reSimplify := regexp.MustCompile(`(?ms:^\s*(auditable: false|redact: false|exit-on-error: true|max-group-size: 100MiB)\n)`)

const defaultFluentConfig = `fluent-defaults: {` +
`buffered-writes: true, ` +
`filter: INFO, ` +
`format: json-fluent-compact, ` +
`redactable: true, ` +
`exit-on-error: false` +
`}, `
stdFileDefaultsRe := regexp.MustCompile(
`file-defaults: \{dir: (?P<path>[^,]+), max-file-size: 10MiB, filter: INFO, format: crdb-v1, redactable: true\}`)
`file-defaults: \{dir: (?P<path>[^,]+), max-file-size: 10MiB, buffered-writes: true, filter: INFO, format: crdb-v1, redactable: true\}`)
fileDefaultsNoMaxSizeRe := regexp.MustCompile(
`file-defaults: \{dir: (?P<path>[^,]+), filter: INFO, format: crdb-v1, redactable: true\}`)
const fileDefaultsNoDir = `file-defaults: {filter: INFO, format: crdb-v1, redactable: true}`
`file-defaults: \{dir: (?P<path>[^,]+), buffered-writes: true, filter: INFO, format: crdb-v1, redactable: true\}`)
const fileDefaultsNoDir = `file-defaults: {buffered-writes: true, filter: INFO, format: crdb-v1, redactable: true}`
const defaultLogDir = `PWD/cockroach-data/logs`
stdCaptureFd2Re := regexp.MustCompile(
`capture-stray-errors: \{enable: true, dir: (?P<path>[^}]+)\}`)
fileCfgRe := regexp.MustCompile(
`\{channels: (?P<chans>[^ ]+), dir: (?P<path>[^,]+), max-file-size: 10MiB, sync-writes: (?P<sync>[^,]+), filter: INFO, format: (?P<format>[^,]+), redactable: true\}`)
`\{channels: (?P<chans>[^ ]+), dir: (?P<path>[^,]+), max-file-size: 10MiB, buffered-writes: (?P<buf>[^,]+), filter: INFO, format: (?P<format>[^,]+), redactable: true\}`)

stderrCfgRe := regexp.MustCompile(
`stderr: {channels: all, filter: (?P<level>[^,]+), format: crdb-v1-tty, redactable: (?P<redactable>[^}]+)}`)
Expand Down Expand Up @@ -110,7 +111,7 @@ func TestSetupLogging(t *testing.T) {
actual = fileDefaultsNoMaxSizeRe.ReplaceAllString(actual, "<fileDefaultsNoMaxSize($path)>")
actual = strings.ReplaceAll(actual, fileDefaultsNoDir, "<fileDefaultsNoDir>")
actual = stdCaptureFd2Re.ReplaceAllString(actual, "<stdCaptureFd2($path)>")
actual = fileCfgRe.ReplaceAllString(actual, "<fileCfg([$chans],$path,$sync,$format)>")
actual = fileCfgRe.ReplaceAllString(actual, "<fileCfg([$chans],$path,$buf,$format)>")
actual = stderrCfgRe.ReplaceAllString(actual, "<stderrCfg($level,$redactable)>")
actual = strings.ReplaceAll(actual, `<stderrCfg(NONE,true)>`, `<stderrDisabled>`)
actual = strings.ReplaceAll(actual, `<stderrCfg(INFO,false)>`, `<stderrEnabledInfoNoRedaction>`)
Expand Down
14 changes: 8 additions & 6 deletions pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,24 +717,26 @@ If problems persist, please see %s.`
// is stopped externally (for example, via the quit endpoint).
select {
case err := <-errChan:
// SetSync both flushes and ensures that subsequent log writes are flushed too.
log.StartSync()
// StartAlwaysFlush both flushes and ensures that subsequent log
// writes are flushed too.
log.StartAlwaysFlush()
return err

case <-stopper.ShouldStop():
// Server is being stopped externally and our job is finished
// here since we don't know if it's a graceful shutdown or not.
<-stopper.IsStopped()
// StartSync both flushes and ensures that subsequent log writes are flushed too.
log.StartSync()
// StartAlwaysFlush both flushes and ensures that subsequent log
// writes are flushed too.
log.StartAlwaysFlush()
return nil

case sig := <-signalCh:
// We start synchronizing log writes from here, because if a
// We start flushing log writes from here, because if a
// signal was received there is a non-zero chance the sender of
// this signal will follow up with SIGKILL if the shutdown is not
// timely, and we don't want logs to be lost.
log.StartSync()
log.StartAlwaysFlush()

log.Ops.Infof(shutdownCtx, "received signal '%s'", sig)
switch sig {
Expand Down
170 changes: 85 additions & 85 deletions pkg/cli/testdata/logflags
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ run
start
----
config: {<stdFileDefaults(<defaultLogDir>)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,true,crdb-v1)>},
<stderrDisabled>},
<stdCaptureFd2(<defaultLogDir>)>}

Expand All @@ -28,13 +28,13 @@ run
start-single-node
----
config: {<stdFileDefaults(<defaultLogDir>)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,true,crdb-v1)>},
<stderrDisabled>},
<stdCaptureFd2(<defaultLogDir>)>}

Expand Down Expand Up @@ -98,13 +98,13 @@ start
--store=path=/pathB
----
config: {<stdFileDefaults(/pathA/logs)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/pathA/logs,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],/pathA/logs,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/pathA/logs,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/pathA/logs,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/pathA/logs,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/pathA/logs,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/pathA/logs,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/pathA/logs,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],/pathA/logs,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/pathA/logs,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/pathA/logs,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/pathA/logs,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/pathA/logs,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/pathA/logs,true,crdb-v1)>},
<stderrDisabled>},
<stdCaptureFd2(/pathA/logs)>}

Expand All @@ -115,13 +115,13 @@ start
--log=file-defaults: {dir: /mypath}
----
config: {<stdFileDefaults(/mypath)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/mypath,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],/mypath,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/mypath,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/mypath,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/mypath,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/mypath,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/mypath,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/mypath,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],/mypath,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/mypath,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/mypath,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/mypath,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/mypath,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/mypath,true,crdb-v1)>},
<stderrDisabled>},
<stdCaptureFd2(/mypath)>}

Expand All @@ -133,13 +133,13 @@ start
--log=file-defaults: {dir: /pathA/logs}
----
config: {<stdFileDefaults(/pathA/logs)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/pathA/logs,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],/pathA/logs,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/pathA/logs,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/pathA/logs,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/pathA/logs,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/pathA/logs,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/pathA/logs,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/pathA/logs,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],/pathA/logs,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/pathA/logs,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/pathA/logs,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/pathA/logs,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/pathA/logs,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/pathA/logs,true,crdb-v1)>},
<stderrDisabled>},
<stdCaptureFd2(/pathA/logs)>}

Expand All @@ -156,13 +156,13 @@ start
--log=file-defaults: {dir: /mypath}
----
config: {<stdFileDefaults(/mypath)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/mypath,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],/mypath,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/mypath,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/mypath,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/mypath,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/mypath,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/mypath,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/mypath,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],/mypath,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/mypath,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/mypath,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/mypath,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/mypath,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/mypath,true,crdb-v1)>},
<stderrDisabled>},
<stdCaptureFd2(/mypath)>}

Expand All @@ -172,13 +172,13 @@ start
--log=sinks: {stderr: {filter: ERROR}}
----
config: {<stdFileDefaults(<defaultLogDir>)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,true,crdb-v1)>},
<stderrCfg(ERROR,true)>},
<stdCaptureFd2(<defaultLogDir>)>}

Expand All @@ -189,13 +189,13 @@ start
--log=capture-stray-errors: {enable: false}
----
config: {<stdFileDefaults(<defaultLogDir>)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,true,crdb-v1)>},
<stderrDisabled>}}

# Logging to stderr without stderr capture causes an error in the default config.
Expand Down Expand Up @@ -236,13 +236,13 @@ start
--log-dir=/mypath
----
config: {<stdFileDefaults(/mypath)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/mypath,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],/mypath,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/mypath,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/mypath,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/mypath,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/mypath,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/mypath,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/mypath,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],/mypath,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/mypath,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/mypath,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/mypath,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/mypath,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/mypath,true,crdb-v1)>},
<stderrDisabled>},
<stdCaptureFd2(/mypath)>}

Expand All @@ -254,13 +254,13 @@ start
--log-dir=/pathA
----
config: {<stdFileDefaults(/pathA)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/pathA,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],/pathA,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/pathA,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/pathA,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/pathA,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/pathA,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/pathA,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],/pathA,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],/pathA,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],/pathA,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],/pathA,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],/pathA,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],/pathA,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],/pathA,true,crdb-v1)>},
<stderrDisabled>},
<stdCaptureFd2(/pathA)>}

Expand All @@ -274,7 +274,7 @@ init
config: {<fileDefaultsNoMaxSize(/mypath)>,
sinks: {file-groups: {default: {channels: all,
dir: /mypath,
sync-writes: false,
buffered-writes: true,
filter: INFO,
format: crdb-v1,
redactable: true}},
Expand All @@ -287,13 +287,13 @@ start
--logtostderr=INFO
----
config: {<stdFileDefaults(<defaultLogDir>)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,true,crdb-v1)>},
<stderrCfg(INFO,true)>},
<stdCaptureFd2(<defaultLogDir>)>}

Expand All @@ -303,13 +303,13 @@ start
--logtostderr
----
config: {<stdFileDefaults(<defaultLogDir>)>,
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,false,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,false,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,true,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,true,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,false,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,false,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,false,crdb-v1)>},
sinks: {file-groups: {default: <fileCfg(['DEV,OPS,HEALTH,SQL_SCHEMA,USER_ADMIN,PRIVILEGES'],<defaultLogDir>,true,crdb-v1)>,
pebble: <fileCfg([STORAGE],<defaultLogDir>,true,crdb-v1)>,
sql-audit: <fileCfg([SENSITIVE_ACCESS],<defaultLogDir>,false,crdb-v1-count)>,
sql-auth: <fileCfg([SESSIONS],<defaultLogDir>,false,crdb-v1-count)>,
sql-exec: <fileCfg([SQL_EXEC],<defaultLogDir>,true,crdb-v1)>,
sql-slow: <fileCfg([SQL_PERF],<defaultLogDir>,true,crdb-v1)>,
sql-slow-internal-only: <fileCfg([SQL_INTERNAL_PERF],<defaultLogDir>,true,crdb-v1)>},
<stderrCfg(INFO,true)>},
<stdCaptureFd2(<defaultLogDir>)>}

Expand Down
6 changes: 3 additions & 3 deletions pkg/util/log/clog.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ func (l *loggerT) outputLogEntry(entry logEntry) {
// are disabled. See IsActive() and its callers for details.
setActive()
var fatalTrigger chan struct{}
extraSync := false
extraFlush := false

if entry.sev == severity.FATAL {
extraSync = true
extraFlush = true
logging.signalFatalCh()

switch traceback {
Expand Down Expand Up @@ -377,7 +377,7 @@ func (l *loggerT) outputLogEntry(entry logEntry) {
// The sink was not accepting entries at this level. Nothing to do.
continue
}
if err := s.sink.output(extraSync, bufs.b[i].Bytes()); err != nil {
if err := s.sink.output(extraFlush, bufs.b[i].Bytes()); err != nil {
if !s.criticality {
// An error on this sink is not critical. Just report
// the error and move on.
Expand Down
Loading

0 comments on commit baf49d1

Please sign in to comment.