Skip to content

Commit

Permalink
util/log: deflake tests that use SQL connections
Browse files Browse the repository at this point in the history
The pgwire code uses goroutines whose execution extends past the
server's stopper's `Stop()` call. This is arguably a mis-design which
needs to be fixed -- but in the meantime the logging package needs to
tolerate it. This patch ensures that asynchronous `log` calls can be
performed concurrently with a `TestLogScope`'s `Close()` call.

Release note: None
  • Loading branch information
knz committed Nov 30, 2020
1 parent 94a429b commit ef184b7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/util/log/clog.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,13 @@ func (l *loggerT) outputLogEntry(entry logpb.Entry) {
// not eliminate the event.
someSinkActive := false
for i, s := range l.sinkInfos {
if entry.Severity < s.threshold || !s.sink.active() {
// Note: we need to use the .Get() method instead of reading the
// severity threshold directly, because some tests are unruly and
// let goroutines live and perform log calls beyond their
// Stopper's Stop() call (e.g. the pgwire async processing
// goroutine). These asynchronous log calls are concurrent with
// the stderrSinkInfo update in (*TestLogScope).Close().
if entry.Severity < s.threshold.Get() || !s.sink.active() {
continue
}
editedEntry := maybeRedactEntry(entry, s.editor)
Expand Down

0 comments on commit ef184b7

Please sign in to comment.