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

pkg/sqlutil: queryLogger must handle non-positive timeouts and inspect context errors; support custom timing thresholds #530

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

jmank88
Copy link
Collaborator

@jmank88 jmank88 commented May 23, 2024

https://smartcontract-it.atlassian.net/browse/BCF-3245

Handle non-positive timeouts gracefully and inspect the context error. In the case of cancelled or unknown error, just return. Only try to calculate how much of the timeout was used for success and explicit context.DeadlineExceeded.

https://smartcontract-it.atlassian.net/browse/BCF-3252

Support customizable thresholds via context values.

Supports:

krehermann
krehermann previously approved these changes May 23, 2024
Copy link
Contributor

@krehermann krehermann left a comment

Choose a reason for hiding this comment

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

nit/ typo in PR name "timoeouts"

patrickhuie19
patrickhuie19 previously approved these changes May 23, 2024
@jmank88 jmank88 changed the title pkg/sqlutil: queryLogger must handle non-positive timoeouts pkg/sqlutil: queryLogger must handle non-positive timeouts May 23, 2024
@jmank88 jmank88 dismissed stale reviews from patrickhuie19 and krehermann via 7a332d4 May 23, 2024 18:34
@jmank88 jmank88 force-pushed the query-log-negative branch from a2f000d to 7a332d4 Compare May 23, 2024 18:34
@jmank88 jmank88 requested a review from patrickhuie19 May 23, 2024 18:34
patrickhuie19
patrickhuie19 previously approved these changes May 23, 2024
@jmank88 jmank88 force-pushed the query-log-negative branch from 7a332d4 to 5072110 Compare May 24, 2024 14:34
@jmank88 jmank88 changed the title pkg/sqlutil: queryLogger must handle non-positive timeouts pkg/sqlutil: queryLogger must handle non-positive timeouts and inspect context errors May 24, 2024
patrickhuie19
patrickhuie19 previously approved these changes May 24, 2024
@jmank88 jmank88 force-pushed the query-log-negative branch from 5072110 to 8ba5ea9 Compare May 29, 2024 15:37
if t == nil {
return ctx
}
return context.WithValue(ctx, ctxKeyLogThresholds{}, *t)
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool! Glad to see us using values in contexts finally, I've wondered why we don't use them more.

Although I hope this won't interfere with any future use of them. If some component needs to have a value attached to a context, but also needs it to have a deadline with custom thresholds, is there a clean way for those to co-exist?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The context key used here is an unexported type, so nothing outside of this package can use the same key and conflict with it.

@jmank88 jmank88 force-pushed the query-log-negative branch from 8d938d2 to 3154f0c Compare June 5, 2024 14:31
@jmank88 jmank88 force-pushed the query-log-negative branch from 3154f0c to e330f6e Compare June 5, 2024 14:39
@jmank88 jmank88 changed the title pkg/sqlutil: queryLogger must handle non-positive timeouts and inspect context errors pkg/sqlutil: queryLogger must handle non-positive timeouts and inspect context errors; support custom timing thresholds Jun 5, 2024
@jmank88 jmank88 requested a review from samsondav June 5, 2024 14:44
@jmank88 jmank88 merged commit 316b5eb into main Jun 5, 2024
8 checks passed
@jmank88 jmank88 deleted the query-log-negative branch June 5, 2024 18:18
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.

4 participants