Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: don't print trace if empty #106280

Merged
merged 1 commit into from
Jul 7, 2023
Merged

Conversation

adityamaru
Copy link
Contributor

This change adds a conditional to only print the
trace of context cancelled request if the trace is not empty. This avoids log spam noticed in #105378.

Fixes: #105378
Release note: None

@adityamaru adityamaru requested a review from erikgrinaker July 6, 2023 14:13
@adityamaru adityamaru requested review from a team as code owners July 6, 2023 14:13
@blathers-crl
Copy link

blathers-crl bot commented Jul 6, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider printing the error, but not the trace if empty

pErr.GoError().Error(), sp.GetConfiguredRecording().String())
recording := sp.GetConfiguredRecording()
if recording.Len() != 0 {
log.Infof(ctx, "batch request %s failed with error: %s\ntrace:\n%s", args.String(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we want to see the batch error object even if the recording is empty?

Also, plse print pErr.GoError() and not call .Error(). This will ensure that the non-redactable bits of the error show up in logs properly.

(nit Also use %v for the error. )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The errors will always be context canceled or context deadline exceeded because we only log the line if ctx.Err() != nil. I don't have a sense for whether this is useful for the HeartbeatTxn, QueryTxn, and EndTxn requests that @erikgrinaker pointed out as spamming the logs in some roachtests?

Thanks for the pointer on the error message format, fixing that up now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ExportRequests by backups (which is what motivated me to add this logline) we always expect a non-empty tracing span as they are sent with a Structured recording. If for some reason there is no trace, we'd see the context cancelled/timed out error on the client side anyways so there isn't much value in printing it here too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's err on the side of not logging here. Generally, we only want to see this when we're reasonably sure that there's a human who requested the trace (is there a better way to determine that?). If they trigger for any random request, we'll get thousands of log lines for internal requests that noone cares about.

pkg/server/node.go Outdated Show resolved Hide resolved
This change adds a conditional to only print the
trace of context cancelled request if the trace is not empty.
This avoids log spam noticed in cockroachdb#105378.

Fixes: cockroachdb#105378
Release note: None
@adityamaru
Copy link
Contributor Author

bors r=knz

@craig
Copy link
Contributor

craig bot commented Jul 7, 2023

Build succeeded:

@craig craig bot merged commit 21904db into cockroachdb:master Jul 7, 2023
@adityamaru adityamaru deleted the spam-trace branch July 7, 2023 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

server: spammy trace logging on context cancellation
4 participants