-
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
*: add last ru consumption for tidb_last_query_info #49769
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2351,23 +2351,6 @@ func runStmt(ctx context.Context, se *session, s sqlexec.Statement) (rs sqlexec. | |
|
||
sessVars := se.sessionVars | ||
|
||
// Record diagnostic information for DML statements | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a behavior change. Before this PR, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most errors occur during the execution stage, before it records the error of the compile+optimize stage. I think it's reasonable move to here. and you can see the manual test on the issue text. I kill the pd, it can record There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @djshow832 is it ok to move to FinishExecuteStmt? |
||
if stmt, ok := s.(*executor.ExecStmt).StmtNode.(ast.DMLNode); ok { | ||
// Keep the previous queryInfo for `show session_states` because the statement needs to encode it. | ||
if showStmt, ok := stmt.(*ast.ShowStmt); !ok || showStmt.Tp != ast.ShowSessionStates { | ||
defer func() { | ||
sessVars.LastQueryInfo = sessionstates.QueryInfo{ | ||
TxnScope: sessVars.CheckAndGetTxnScope(), | ||
StartTS: sessVars.TxnCtx.StartTS, | ||
ForUpdateTS: sessVars.TxnCtx.GetForUpdateTS(), | ||
} | ||
if err != nil { | ||
sessVars.LastQueryInfo.ErrMsg = err.Error() | ||
} | ||
}() | ||
} | ||
} | ||
|
||
// Save origTxnCtx here to avoid it reset in the transaction retry. | ||
origTxnCtx := sessVars.TxnCtx | ||
err = se.checkTxnAborted(s) | ||
|
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.
Another question: is it better that when the statement type is not exec or dml, the lastQueryInfo/LastRUConsumption should be reset instead of just keep unchanged?
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 we can keep unchanged.