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

sql: limit statistics discard log message #110805

Merged
merged 1 commit into from Sep 20, 2023
Merged

sql: limit statistics discard log message #110805

merged 1 commit into from Sep 20, 2023

Conversation

j82w
Copy link
Contributor

@j82w j82w commented Sep 18, 2023

Problem:
The discard log message occurs for every transaction end after the limit is hit. This causes the log to be flooded with discard messages. This is not useful for users and can cause issues with telemetry pipelines.

Solution:
The discard message will only be logged once per minute. The log rate is controlled by a cluster setting. This allows the message to be set to a very large interval if this expected behavior for a cluster.

Refactored:
The SQLStats creates and hold the reference to the counts. Then each container which is per an app name is passed the counts by reference. It's not obvious that the counts are shared between the containers. The code was refactored to make a single object to hold the counts and pass all the related content together. This makes the code easier to read and expand in the future if other values need to be added.

Fixes: #110454

Release note (sql change): The discard log message is now limited to once per minute by default. The message was also changed to have both the number of transactions and the number of statements that were discarded.

@blathers-crl
Copy link

blathers-crl bot commented Sep 18, 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

Problem:
The discard log message occurs for every transaction end after the limit
is hit. This causes the log to be flooded with discard messages. This
is not useful for users and can cause issues with telemetry pipelines.

Solution:
The discard message will only be logged once per minute. The log rate
is controlled by a cluster setting. This allows the message to be set
to a very large message if this expected behavior for a cluster.

Refactored:
The SQLStats creates and hold the reference to the counts. Then each
container which is per an app name is passed the counts by reference.
It's not obvious that the counts are shared between the containers. The
code was refactored to make a single object to hold the counts and pass
all the related content together. This makes the code easier to read and
expand in the future if other values need to be added.

Fixes: #110454

Release note (sql change): The discard log message is now limited to
once per minute by default. The message was also changed to have both
the number of transactions and the number of statements that were
discarded.
@j82w j82w marked this pull request as ready for review September 19, 2023 21:25
@j82w j82w requested a review from a team as a code owner September 19, 2023 21:25
Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

really nice refactor!
:lgtm:

Reviewed 8 of 8 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @j82w)

@j82w
Copy link
Contributor Author

j82w commented Sep 20, 2023

bors r+

@j82w j82w added the backport-23.1.x Flags PRs that need to be backported to 23.1 label Sep 20, 2023
@craig
Copy link
Contributor

craig bot commented Sep 20, 2023

Build succeeded:

@craig craig bot merged commit db64500 into cockroachdb:master Sep 20, 2023
8 checks passed
@blathers-crl
Copy link

blathers-crl bot commented Sep 20, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from 91af030 to blathers/backport-release-23.1-110805: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 23.1.x failed. See errors above.


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

@j82w j82w added release-blocker Indicates a release-blocker. Use with branch-release-2x.x label to denote which branch is blocked. and removed release-blocker Indicates a release-blocker. Use with branch-release-2x.x label to denote which branch is blocked. labels Oct 2, 2023
craig bot pushed a commit that referenced this pull request Oct 3, 2023
111613: sqlstats: fix counter for in-memory fingerprints r=j82w a=j82w

Problem:
The counters used to track the number of unique fingerprints we store in-memory for sql stats were refactored in #110805. In change #110805 a bug was introduced where it incresease the memory instead of resetting the counts. This causes the statstics to stop calculating new stats once the limit is hit.

Solution:
Fix the bug by resetting the counters instead of increasing them. Added new test to test the reset functionality.

Fixes: #111583

Release note (sql change): Fix a bug that causes the sql stats to stop collecting new stats.

Co-authored-by: j82w <jwilley@cockroachlabs.com>
blathers-crl bot pushed a commit that referenced this pull request Oct 3, 2023
Problem:
The counters used to track the number of unique fingerprints we store
in-memory for sql stats were refactored in #110805. In change #110805
a bug was introduced where it incresease the memory instead of resetting
the counts. This causes the statstics to stop calculating new stats
once the limit is hit.

Solution:
Fix the bug by resetting the counters instead of increasing them. Added
new test to test the reset functionality.

Fixes: #111583

Release note (sql change): Fix a bug that causes the sql stats to stop
collecting new stats.
THardy98 pushed a commit to THardy98/cockroach that referenced this pull request Oct 6, 2023
Problem:
The counters used to track the number of unique fingerprints we store
in-memory for sql stats were refactored in cockroachdb#110805. In change cockroachdb#110805
a bug was introduced where it incresease the memory instead of resetting
the counts. This causes the statstics to stop calculating new stats
once the limit is hit.

Solution:
Fix the bug by resetting the counters instead of increasing them. Added
new test to test the reset functionality.

Fixes: cockroachdb#111583

Release note (sql change): Fix a bug that causes the sql stats to stop
collecting new stats.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: reduce log frequency of statistics discarded due to memory limit
3 participants