-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
topsql: introduce pub/sub mode #29020
Conversation
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
/cc @crazycs520 @mornyx @breeswish |
@zhongzc: GitHub didn't allow me to request PR reviews from the following users: mornyx. Note that only pingcap members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
/run-unit-test |
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
Co-authored-by: crazycs <crazycs520@gmail.com>
@@ -57,6 +57,9 @@ func TestMain(m *testing.M) { | |||
goleak.IgnoreTopFunction("go.etcd.io/etcd/pkg/logutil.(*MergeLogger).outputLoop"), | |||
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"), | |||
goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun"), | |||
goleak.IgnoreTopFunction("time.Sleep"), | |||
goleak.IgnoreTopFunction("runtime/pprof.readProfile"), | |||
goleak.IgnoreTopFunction("github.com/pingcap/tidb/util/topsql/tracecpu.(*sqlCPUProfiler).startAnalyzeProfileWorker"), |
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 don't think it may not be accepted to let this function leak.
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
// EnablePProfSQLCPU is true means want to keep the `sql` label. Otherwise, remove the `sql` label. | ||
EnablePProfSQLCPU = atomic.NewBool(false) | ||
|
||
// PrecisionSeconds indicates profile interval. | ||
PrecisionSeconds = atomic.NewInt64(DefPrecisionSeconds) |
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.
They should be a config of sqlCPUProfiler I think, from this module's perspective.
} | ||
}, nil) | ||
|
||
<-ctx.Done() |
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.
If you are waiting goroutine to finish, why not execute it in current goroutine directly?
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.
That spawned goroutine may block when the deadline is exceeded, in that case, this datasink should be closed.
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.
Got it. You can add a comment to document the reason.
func (sp *sqlCPUProfiler) IsEnabled() bool { | ||
return variable.TopSQLEnabled() || sp.hasExportProfileTask() | ||
// ShouldProfile return true if it's required to profile. It exports for tests. | ||
func (sp *sqlCPUProfiler) ShouldProfile() bool { |
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.
Why it is not checking the enabling state?
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.
Which enabling state?
@zhongzc: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What problem does this PR solve?
Make the diagnostic node dependent on TiDB instead of TiDB dependent on the diagnostic node to reverse the dependency to a normal form.
Depends on: pingcap/tipb#242
Related: tikv/tikv#11087
What is changed and how it works?
Global variable
tidb_enable_top_sql
doesn't affect whether to enable topsql or not on current instance directly.Provide gRPC service
tipb.TopSQLPubSubServer
Modify interface
ReportClient
DataSink
IsPaused
,IsDown
. Reporter uses them to enable/disable TopSQL.pubSubDataSink
for connecting the reporter and external subscribersCheck List
Tests
Side effects
Release note