-
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
*: pass sql, plan digest down to KV request #24854
Conversation
Signed-off-by: crazycs <crazycs520@gmail.com>
Signed-off-by: crazycs <crazycs520@gmail.com>
Signed-off-by: crazycs <crazycs520@gmail.com>
Signed-off-by: crazycs <crazycs520@gmail.com>
Signed-off-by: crazycs <crazycs520@gmail.com>
Signed-off-by: crazycs <crazycs520@gmail.com>
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 think it doesn't look so good that the pessimistic lock requests use a different way to set the resource group tag. I think there should be a better way, but it's ok for now since we don't have too much time.
Signed-off-by: crazycs <crazycs520@gmail.com>
@@ -919,11 +921,11 @@ func (a *ExecStmt) LogSlowQuery(txnTS uint64, succ bool, hasMoreResults bool) { | |||
statsInfos := plannercore.GetStatsInfo(a.Plan) | |||
memMax := sessVars.StmtCtx.MemTracker.MaxConsumed() | |||
diskMax := sessVars.StmtCtx.DiskTracker.MaxConsumed() | |||
_, planDigest := getPlanDigest(a.Ctx, a.Plan) | |||
planDigest := getPlanDigest(a.Ctx, a.Plan) |
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.
Duplicated with line 336?
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.
+1 maybe make getPlanDigest
be memoized, just calculate plan once in 336 and directly reuse result in here
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.
Line 336 uses to initialize the plan digest, and it is already cache in StatementContext
@@ -919,11 +921,11 @@ func (a *ExecStmt) LogSlowQuery(txnTS uint64, succ bool, hasMoreResults bool) { | |||
statsInfos := plannercore.GetStatsInfo(a.Plan) | |||
memMax := sessVars.StmtCtx.MemTracker.MaxConsumed() | |||
diskMax := sessVars.StmtCtx.DiskTracker.MaxConsumed() | |||
_, planDigest := getPlanDigest(a.Ctx, a.Plan) | |||
planDigest := getPlanDigest(a.Ctx, a.Plan) |
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.
+1 maybe make getPlanDigest
be memoized, just calculate plan once in 336 and directly reuse result in here
tidb/store/driver/txn/txn_driver.go Line 96 in 3f0c2a3
will be used in insert/replace code path ( |
Signed-off-by: crazycs <crazycs520@gmail.com>
@lysu , Already call |
/lgtm |
/LGTM |
Signed-off-by: crazycs <crazycs520@gmail.com>
/run-all-tests |
Signed-off-by: crazycs <crazycs520@gmail.com>
/run-all-tests |
/run-all-tests |
/run-e2e-test |
/run-all-tests |
/run-unit-test |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 0b35aba
|
@crazycs520: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. 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 ti-community-infra/tichi repository. |
/run-sqllogic-test-1 |
normalized, sqlDigest := sc.SQLDigest() | ||
if len(normalized) == 0 { | ||
return nil | ||
} | ||
tag = resourcegrouptag.EncodeResourceGroupTag(sqlDigest, sc.planDigest) | ||
sc.resourceGroupTag.Store(tag) |
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.
What about concurrently calling this function?
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.
Concurrently calling doesn't affect correctness.
@@ -183,7 +183,7 @@ func ErrDeadlockToDeadlockRecord(dl *tikverr.ErrDeadlock) *DeadlockRecord { | |||
} | |||
waitChain = append(waitChain, WaitChainItem{ | |||
TryLockTxn: rawItem.Txn, | |||
SQLDigest: sqlDigest, | |||
SQLDigest: hex.EncodeToString(sqlDigest), |
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.
Is it better to be NewDigest(sqlDigest).String()
?
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.
Yes, use NewDigest(sqlDigest).String()
is better.
Track issue: #24875
Related PR: #24380
What problem does this PR solve?
This PR use to implement the part of TopSQL feature.
For TiKV to collection resource by SQL statements, TiDB need pass the
sql digest
andplan digest
down to TiKV.What is changed and how it works?
sql digest
andplan digest
to[]byte
and the set onkv.Context.ResourceGroupTag
.Related PR
Check List
Tests
Side effects
Release note