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

client: KV requests with source label #34833

Merged
merged 3 commits into from
Jul 1, 2022
Merged

Conversation

you06
Copy link
Contributor

@you06 you06 commented May 19, 2022

Signed-off-by: you06 [email protected]

What problem does this PR solve?

Issue Number: close #33963

Problem Summary:

What is changed and how it works?

Add request source when sending KV request, the source tag includes the scope and type of the statement.

Record metrics by request type and source.

image

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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.

Add source labels for KV requests.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented May 19, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • cfzjywxk
  • sticnarf

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 19, 2022
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2022
@you06
Copy link
Contributor Author

you06 commented Jun 10, 2022

/run-unit-test

1 similar comment
@you06
Copy link
Contributor Author

you06 commented Jun 10, 2022

/run-unit-test

@ti-chi-bot ti-chi-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 13, 2022
@ti-chi-bot ti-chi-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 15, 2022
@you06
Copy link
Contributor Author

you06 commented Jun 16, 2022

/run-all-tests

1 similar comment
@you06
Copy link
Contributor Author

you06 commented Jun 16, 2022

/run-all-tests

@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 19, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jun 19, 2022

@you06 you06 marked this pull request as ready for review June 19, 2022 21:00
@you06 you06 requested a review from a team as a code owner June 19, 2022 21:00
@ti-chi-bot ti-chi-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jun 19, 2022
@cfzjywxk
Copy link
Contributor

@you06
Please resolve the conflicts.

@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 27, 2022
@you06
Copy link
Contributor Author

you06 commented Jun 27, 2022

@sticnarf @cfzjywxk PTAL

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 29, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 30, 2022
ddl/ddl_api.go Outdated Show resolved Hide resolved
@@ -132,15 +134,15 @@ func (e *GrantExec) Next(ctx context.Context, req *chunk.Chunk) error {
}
defer func() {
if !isCommit {
_, err := internalSession.(sqlexec.SQLExecutor).ExecuteInternal(context.Background(), "rollback")
_, err := internalSession.(sqlexec.SQLExecutor).ExecuteInternal(ctx, "rollback")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if it's ok to change these background ctx to the parent ctx... Could the original intention be just allowing it even if the parent ctx is done?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Emmm, it seems many RunInNewTxn and ExecuteInternal use context in a messy way(if there is no context in the parameters, create a new one), creating a new context in many places is redundant. Anyway, all the modifies have been checked for compatibility.

@@ -117,6 +118,7 @@ func (e *inspectionResultRetriever) retrieve(ctx context.Context, sctx sessionct
}
e.retrieved = true

ctx = kv.WithInternalSourceType(ctx, kv.InternalTxnMeta)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure whether memtable related things are always internal... If a user reads memory tables, will it come here?

Copy link
Contributor Author

@you06 you06 Jun 30, 2022

Choose a reason for hiding this comment

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

But they call ExecRestrictedSQL which indicates internal usages... If they don't send requests the request source of it won't be used.

@@ -204,6 +205,7 @@ func (e *MetricsSummaryRetriever) retrieve(ctx context.Context, sctx sessionctx.
}
sort.Strings(tables)

ctx = kv.WithInternalSourceType(ctx, kv.InternalTxnOthers)
Copy link
Contributor

Choose a reason for hiding this comment

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

I have questions here similar to retrieving memory table...

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 1, 2022
@you06 you06 force-pushed the request-source branch from 2180283 to af7dd0e Compare July 1, 2022 06:48
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 1, 2022
Copy link
Contributor

@sticnarf sticnarf 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 added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 1, 2022
@you06
Copy link
Contributor Author

you06 commented Jul 1, 2022

Need to update the panel ids after #34845 got merged.

@you06 you06 requested a review from zyguan July 1, 2022 09:07
@you06
Copy link
Contributor Author

you06 commented Jul 1, 2022

@cfzjywxk @longfangsong @zyguan PTAL

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 1, 2022
@cfzjywxk
Copy link
Contributor

cfzjywxk commented Jul 1, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 4eaae7a40226ce720ef93f633fece4905c8deac5

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 1, 2022
you06 added 3 commits July 1, 2022 19:21
Signed-off-by: you06 <[email protected]>

fix tests

Signed-off-by: you06 <[email protected]>

fix test

Signed-off-by: you06 <[email protected]>

update

Signed-off-by: you06 <[email protected]>

update bazel

Signed-off-by: you06 <[email protected]>

fix test

Signed-off-by: you06 <[email protected]>

fix test

Signed-off-by: you06 <[email protected]>

update

Signed-off-by: you06 <[email protected]>

update client-go

Signed-off-by: you06 <[email protected]>

update client-go

Signed-off-by: you06 <[email protected]>

update grafana

Signed-off-by: you06 <[email protected]>

update bazel

Signed-off-by: you06 <[email protected]>

display by stack

Signed-off-by: you06 <[email protected]>

set request source for ctx of

Signed-off-by: you06 <[email protected]>

address comment

Signed-off-by: you06 <[email protected]>

address comment

Signed-off-by: you06 <[email protected]>

parser, ddl: support decoding binary literal in set/enum (pingcap#35822)

close pingcap#31338

executor: fix a nil point when @@tidb_enable_collect_execution_info is off and cop cache is on (pingcap#35839)

close pingcap#35829

ddl: support drop columns for multi-schema change (pingcap#35737)

ref pingcap#14766

planner: don't push down predicates over table dual (pingcap#35669)

close pingcap#35527

*: Remove some useless staleness code (pingcap#35849)

close pingcap#35848

ddl: fix potential wrong column definition when setting default value (pingcap#35845)

close pingcap#35846

*: add timeout for test cases (pingcap#35844)

ddl: remove `onDropColumns` and `onAddColumns` (pingcap#35862)

ref pingcap#14766

*: Fix Dockerfile (pingcap#35835)

close pingcap#35828

server: refactor TestConnExecutionTimeout (pingcap#35865)

close pingcap#35868

fix test

Signed-off-by: you06 <[email protected]>

fix lint

Signed-off-by: you06 <[email protected]>
Signed-off-by: you06 <[email protected]>
@you06 you06 force-pushed the request-source branch from 4eaae7a to 706ec0e Compare July 1, 2022 11:22
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Jul 1, 2022
@cfzjywxk
Copy link
Contributor

cfzjywxk commented Jul 1, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 706ec0e

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 1, 2022
@ti-chi-bot ti-chi-bot merged commit 65e0b8e into pingcap:master Jul 1, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jul 1, 2022

TiDB MergeCI notify

✅ Well Done! New fixed [2] after this pr merged.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-common-test ✅ all 11 tests passed 18 min Fixed
idc-jenkins-ci-tidb/common-test ✅ all 12 tests passed 9 min 43 sec Fixed
idc-jenkins-ci/integration-cdc-test 🟢 all 35 tests passed 24 min Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 6 min 42 sec Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 5 min 14 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 5 min 4 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 4 min 27 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 3 min 3 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 2 min 52 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

diagnose: try to differentiate between internal and external requests
5 participants