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

statistics: add sampling logger #51741

Merged
merged 4 commits into from
Mar 14, 2024

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Mar 13, 2024

What problem does this PR solve?

Issue Number: ref #50132

Problem Summary:

If table analysis fails or there are no tables to analyze, we need to avoid printing duplicate logs.

What changed and how does it work?

We have added a sampling logger that prints only two same logs within a minute. However, please note that we cannot keep creating the logger repeatedly. It is necessary to keep it as a singleton so that we can track the same log counts with the same logger. Otherwise, the logger won't function as intended.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 13, 2024
Copy link
Member Author

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

@Rustin170506
Copy link
Member Author

Rustin170506 commented Mar 13, 2024

Tested locally, only two logs per minute

[2024/03/13 18:23:23.553 +08:00] [INFO] [refresher.go:124] ["No table to analyze"] [category=stats]
[2024/03/13 18:23:24.500 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/13 18:23:26.552 +08:00] [INFO] [refresher.go:124] ["No table to analyze"] [category=stats]
[2024/03/13 18:23:34.500 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/13 18:23:44.500 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/13 18:23:54.500 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/13 18:24:04.500 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/13 18:24:14.500 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/13 18:24:15.126 +08:00] [INFO] [manager.go:364] ["get owner"] ["owner info"="[log-backup] /tidb/br-stream/owner ownerManager 265674cb-6155-4005-aece-362f37fc0ab5"] ["owner key"=/tidb/br-stream/owner/22318e375664bef6] [ownerID=265674cb-6155-4005-aece-362f37fc0ab5] [op=none]
[2024/03/13 18:24:20.526 +08:00] [INFO] [owner_daemon.go:56] ["daemon became owner"] [id=265674cb-6155-4005-aece-362f37fc0ab5] [daemon-id=LogBackup::Advancer]
[2024/03/13 18:24:20.527 +08:00] [INFO] [advancer.go:503] ["Subscription handler spawned."] [category="log backup subscription manager"]
[2024/03/13 18:24:24.500 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/13 18:24:26.552 +08:00] [INFO] [refresher.go:124] ["No table to analyze"] [category=stats]

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Merging #51741 (7d05e02) into master (cd60e7f) will increase coverage by 0.2538%.
Report is 17 commits behind head on master.
The diff coverage is 85.7142%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #51741        +/-   ##
================================================
+ Coverage   72.4691%   72.7230%   +0.2538%     
================================================
  Files          1474       1476         +2     
  Lines        363628     439964     +76336     
================================================
+ Hits         263518     319955     +56437     
- Misses        80708      99962     +19254     
- Partials      19402      20047       +645     
Flag Coverage Δ
integration 48.9251% <0.0000%> (?)
unit 70.4831% <85.7142%> (-1.8695%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9957% <ø> (-2.3014%) ⬇️
parser ∅ <ø> (∅)
br 50.9772% <ø> (+4.5642%) ⬆️

@Rustin170506
Copy link
Member Author

/retest

@Rustin170506
Copy link
Member Author

/retest

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

Rest LGTM

pkg/statistics/handle/logutil/logutil.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 14, 2024
Signed-off-by: hi-rustin <[email protected]>
@Rustin170506
Copy link
Member Author

Tested again:

[2024/03/14 11:41:34.669 +08:00] [INFO] [refresher.go:119] ["No table to analyze"] [category=stats]
[2024/03/14 11:41:37.673 +08:00] [INFO] [refresher.go:119] ["No table to analyze"] [category=stats]
[2024/03/14 11:41:44.638 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/14 11:41:54.639 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/14 11:42:04.638 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/14 11:42:14.639 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/14 11:42:24.639 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/14 11:42:26.628 +08:00] [INFO] [manager.go:364] ["get owner"] ["owner info"="[log-backup] /tidb/br-stream/owner ownerManager d3c4000e-0c69-455c-8c1e-ec117bfcc989"] ["owner key"=/tidb/br-stream/owner/22318e3b0ce0e2f5] [ownerID=d3c4000e-0c69-455c-8c1e-ec117bfcc989] [op=none]
[2024/03/14 11:42:31.633 +08:00] [INFO] [owner_daemon.go:56] ["daemon became owner"] [id=d3c4000e-0c69-455c-8c1e-ec117bfcc989] [daemon-id=LogBackup::Advancer]
[2024/03/14 11:42:31.635 +08:00] [INFO] [advancer.go:503] ["Subscription handler spawned."] [category="log backup subscription manager"]
[2024/03/14 11:42:34.639 +08:00] [WARN] [cgmon.go:128] ["failed to get cgroup memory limit"] [error="failed to read memory cgroup from cgroups file: /proc/self/cgroup: open /proc/self/cgroup: no such file or directory"]
[2024/03/14 11:42:34.678 +08:00] [INFO] [refresher.go:119] ["No table to analyze"] [category=stats]
[2024/03/14 11:42:37.671 +08:00] [INFO] [refresher.go:119] ["No table to analyze"] [category=stats]

Signed-off-by: hi-rustin <[email protected]>
Copy link
Member Author

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

@Rustin170506 Rustin170506 requested a review from AilinKid March 14, 2024 03:45
Copy link
Contributor

@elsa0520 elsa0520 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 14, 2024
@Rustin170506
Copy link
Member Author

/retest

Copy link

ti-chi-bot bot commented Mar 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, elsa0520

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 14, 2024
Copy link

ti-chi-bot bot commented Mar 14, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-14 04:13:42.094485692 +0000 UTC m=+918049.116732081: ☑️ agreed by elsa0520.
  • 2024-03-14 05:08:52.81090023 +0000 UTC m=+921359.833146614: ☑️ agreed by AilinKid.

@ti-chi-bot ti-chi-bot bot merged commit 1718d7b into pingcap:master Mar 14, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved component/statistics lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants