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

Log when DB queries return large numbers of rows #2338

Merged
merged 4 commits into from
Aug 10, 2021

Conversation

andy-paine
Copy link
Contributor

A short explanation of the proposed change

Add some extra logging for when DB queries return a large number of rows including a configuration flag which can both toggle the feature off as well as set a threshold for when to log.

An explanation of the use cases your change solves

We've seen some DB queries return large numbers of rows which CC then has to parse/marshal which can be particularly slow. By adding some additional logging when queries return lots of data we can hopefully identify specific requests that cause large numbers or rows to be handled.

We've also looked at using pg_stat_statments but by using the existing Steno logger in CC we can identify a specific request as our users submit error reports about slow endpoints including the VCAP request ID.

Links to any other associated PRs

Slow service plan visibilities caused by large numbers of returned rows - #2215

Checks

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@sethboyles
Copy link
Member

@andy-paine thanks for the PR. Is there an associated capi-release PR to allow configuration of the query_size_log_threshold field?

johha and others added 2 commits July 28, 2021 17:42
Threshold acts as both a way to avoid polluting logs with queries that
only produce a few rows as well as a way to toggle this behaviour off
so it only affects users who opt-in
andy-paine added a commit to sap-contributions/capi-release that referenced this pull request Jul 28, 2021
Allow configuring of the threshold above which large queries should be
logged

See cloudfoundry/cloud_controller_ng#2338
@andy-paine
Copy link
Contributor Author

Rebased this branch and added a CAPI PR cloudfoundry/capi-release#200 now 🙂

andy-paine and others added 2 commits July 29, 2021 08:35
Ensure that extra logs will only be emitted when user opts in by
providing threshold
The format of these logs is slightly different between mysql and
postgres but they seem functionally the same so we can just test for
either type of quoting
@sethboyles sethboyles merged commit b241622 into cloudfoundry:main Aug 10, 2021
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.

5 participants