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

query_executor: Record WaitingForConnection stat in all cases #15073

Merged
merged 6 commits into from
Jan 31, 2024

Conversation

tycol7
Copy link
Contributor

@tycol7 tycol7 commented Jan 29, 2024

Description

Record the WaitingForConnection stat whether or not the connection succeeds. This stat is needed in the error path for metrics and logging.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

N/A

The `WaitingForConnection` stat is also needed in the error path for
metrics and logging.

Signed-off-by: Tyler Coleman <[email protected]>
Copy link
Contributor

vitess-bot bot commented Jan 29, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Jan 29, 2024
@github-actions github-actions bot added this to the v19.0.0 milestone Jan 29, 2024
Apply the same logic as `getConn`, i.e., record the stat even in error
paths (for `getStreamConn`).

Signed-off-by: Tyler Coleman <[email protected]>
@tycol7 tycol7 changed the title Record WaitingForConnection stat in all cases query_executor: Record WaitingForConnection stat in all cases Jan 29, 2024
@tycol7 tycol7 marked this pull request as ready for review January 30, 2024 00:01
@deepthi deepthi added Component: Query Serving Component: Observability Pull requests that touch tracing/metrics/monitoring Type: Enhancement Logical improvement (somewhere between a bug and feature) and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Jan 30, 2024
Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

It will be good to add a unit test. There should be some existing stats tests that you can either extend or use as a pattern.

@@ -778,9 +778,10 @@ func (qre *QueryExecutor) getConn() (*connpool.PooledConn, error) {
start := time.Now()
conn, err := qre.tsv.qe.conns.Get(ctx, qre.setting)

qre.logStats.WaitingForConnection += time.Since(start)
Copy link
Member

Choose a reason for hiding this comment

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

It's probably better to do this in a defer call right after start is initialized. That will be future-proof.

Copy link
Contributor Author

@tycol7 tycol7 Jan 30, 2024

Choose a reason for hiding this comment

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

@deepthi
Copy link
Member

deepthi commented Jan 30, 2024

@systay @harshit-gangal should we require an issue for this change?

@deepthi deepthi added the NeedsIssue A linked issue is missing for this Pull Request label Jan 30, 2024
Wrapping the stat increment in a defer function future-proofs these
changes by always incrementing the stat before returning from the
surrounding function.

Signed-off-by: Tyler Coleman <[email protected]>
Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: 599 lines in your changes are missing coverage. Please review.

Comparison is base (eddb39e) 47.29% compared to head (c1efce6) 47.71%.
Report is 83 commits behind head on main.

Files Patch % Lines
...vt/vtgate/planbuilder/operators/sharded_routing.go 0.00% 42 Missing ⚠️
go/vt/vtgate/evalengine/cached_size.go 0.00% 41 Missing ⚠️
go/vt/vtgate/planbuilder/operators/delete.go 0.00% 32 Missing ⚠️
.../vtgate/planbuilder/operators/delete_with_input.go 0.00% 31 Missing ⚠️
.../vtgate/planbuilder/operators/horizon_expanding.go 0.00% 31 Missing ⚠️
go/vt/mysqlctl/backupengine.go 7.40% 25 Missing ⚠️
go/vt/vtctl/workflow/traffic_switcher.go 0.00% 25 Missing ⚠️
go/vt/vtgate/engine/delete_with_input.go 53.70% 23 Missing and 2 partials ⚠️
...tgate/planbuilder/operators/aggregation_pushing.go 0.00% 25 Missing ⚠️
go/vt/mysqlctl/builtinbackupengine.go 4.34% 22 Missing ⚠️
... and 57 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15073      +/-   ##
==========================================
+ Coverage   47.29%   47.71%   +0.41%     
==========================================
  Files        1137     1155      +18     
  Lines      238684   240225    +1541     
==========================================
+ Hits       112895   114625    +1730     
+ Misses     117168   117001     -167     
+ Partials     8621     8599      -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tycol7
Copy link
Contributor Author

tycol7 commented Jan 30, 2024

It will be good to add a unit test. There should be some existing stats tests that you can either extend or use as a pattern.

a10c491 + c1efce6

@tycol7 tycol7 requested a review from deepthi January 30, 2024 19:45
For completeness.

Signed-off-by: Tyler Coleman <[email protected]>
@deepthi deepthi removed the NeedsIssue A linked issue is missing for this Pull Request label Jan 31, 2024
Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

LGTM

@deepthi
Copy link
Member

deepthi commented Jan 31, 2024

Attention: 599 lines in your changes are missing coverage. Please review.

Ignoring this for now until we get all CodeCov quirks sorted out.

@deepthi deepthi merged commit 416d7f4 into vitessio:main Jan 31, 2024
102 of 103 checks passed
@deepthi deepthi deleted the tdc-add-wait-stat-to-error-paths branch January 31, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Observability Pull requests that touch tracing/metrics/monitoring Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug Report: Connection wait time statistics not reflected in logs
3 participants