-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: use session pool when locking or unlocking table stats #46611
Merged
ti-chi-bot
merged 16 commits into
pingcap:master
from
Rustin170506:rustin-patch-stats-refactor
Sep 5, 2023
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ac517b4
statistics: add tests for lock/unlock stats
Rustin170506 1388938
statistics: use session pool
Rustin170506 a137cb4
statistics: gen mock
Rustin170506 34c1a05
statistics: gen mock
Rustin170506 b43d107
statistics: fix build
Rustin170506 f864028
Merge branch 'master' into rustin-patch-stats-refactor
Rustin170506 f17e39d
statistics: fix build
Rustin170506 8227912
statistics: fix build
Rustin170506 4bb7f83
statistics: fix build
Rustin170506 85c6ac9
statistics: add more tests
Rustin170506 e9e0508
statistics: add more tests
Rustin170506 83d07bd
statistics: better tests
Rustin170506 6e4c6ea
statistics: add more tests
Rustin170506 2f97917
statistics: add more tests
Rustin170506 35af128
statistics: add more tests
Rustin170506 be8b49e
statistics: better code
Rustin170506 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this PR (in the next few PRs), can we thoroughly detach(decouple)
StatsLock
fromStatsHandler
? Specifically, can we remove allHandle.XXLockedXX
methods (all methods in this filelock_stats_handler.go
) and move them into a new separate package?Logically, if we implement these
XXLockedXX
methods onHandler
, we think the management of locked stats is part of the responsibility ofHandler
, althoughHandler
is big enough and it already has too many responsibilities.Another way is to let the
Handler
just as a consumer of locked stats info. It doesn't update locked stats info and only reads locked stats info from the storage and reacts to it accordingly.I'm not sure whether this can simplify the design and implementation, what do you think of this? @hi-rustin
(I'm not sure whether I explain it clearly...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this really helps. If we want to split the entry from the handle to stats locker. Then we need to put it in the domain or some other global structurations. I guess using the stats handle as an entry point for stats logic is fine. The problem with the handle is that we put too much business logic in the entry point.
Right now, the lock/unlock stats handler is pretty simple:
But I can try it recently to see if this helps. Do you have any suggestions on where to put the `statsLocker/statsUnlocker/statsQuerier'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then in the feature, we can break the huge
StatsHandler
down to multiple smaller sub-components.This makes our code easier to maintain (
maintaining multiple smaller and simpler components
is better thanmaintaining a big and complex component
).And these sub-components rely on the storage to synchronize information instead of relying on memory status, which is much safer.