-
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
executor: make set system variable log shorter #7029
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,7 +334,7 @@ func (s *session) doCommitWithRetry(ctx context.Context) error { | |
// BatchInsert already commit the first batch 1000 rows, then it commit 1000-2000 and retry the statement, | ||
// Finally t1 will have more data than t2, with no errors return to user! | ||
if s.isRetryableError(err) && !s.sessionVars.BatchInsert && commitRetryLimit > 0 { | ||
log.Warnf("[con:%d] retryable error: %v, txn: %v", s.sessionVars.ConnectionID, err, s.txn) | ||
log.Warnf("con:%d retryable error: %v, txn: %v", s.sessionVars.ConnectionID, err, s.txn) | ||
// Transactions will retry 2 ~ commitRetryLimit times. | ||
// We make larger transactions retry less times to prevent cluster resource outage. | ||
txnSizeRate := float64(txnSize) / float64(kv.TxnTotalSizeLimit) | ||
|
@@ -359,7 +359,7 @@ func (s *session) doCommitWithRetry(ctx context.Context) error { | |
} | ||
|
||
if err != nil { | ||
log.Warnf("[con:%d] finished txn:%v, %v", s.sessionVars.ConnectionID, s.txn, err) | ||
log.Warnf("con:%d finished txn:%v, %v", s.sessionVars.ConnectionID, s.txn, err) | ||
return errors.Trace(err) | ||
} | ||
mapper := s.GetSessionVars().TxnCtx.TableDeltaMap | ||
|
@@ -508,17 +508,17 @@ func (s *session) retry(ctx context.Context, maxCnt uint) error { | |
} | ||
} | ||
if !s.isRetryableError(err) { | ||
log.Warnf("[con:%d] session:%v, err:%v in retry", connID, s, err) | ||
log.Warnf("con:%d session:%v, err:%v in retry", connID, s, err) | ||
metrics.SessionRetryErrorCounter.WithLabelValues(metrics.LblUnretryable) | ||
return errors.Trace(err) | ||
} | ||
retryCnt++ | ||
if retryCnt >= maxCnt { | ||
log.Warnf("[con:%d] Retry reached max count %d", connID, retryCnt) | ||
log.Warnf("con:%d Retry reached max count %d", connID, retryCnt) | ||
metrics.SessionRetryErrorCounter.WithLabelValues(metrics.LblReachMax) | ||
return errors.Trace(err) | ||
} | ||
log.Warnf("[con:%d] retryable error: %v, txn: %v", connID, err, s.txn) | ||
log.Warnf("con:%d retryable error: %v, txn: %v", connID, err, s.txn) | ||
kv.BackOff(retryCnt) | ||
s.txn.changeToInvalid() | ||
s.sessionVars.SetStatusFlag(mysql.ServerStatusInTrans, false) | ||
|
@@ -739,7 +739,7 @@ func (s *session) executeStatement(ctx context.Context, connID uint64, stmtNode | |
recordSet, err := runStmt(ctx, s, stmt) | ||
if err != nil { | ||
if !kv.ErrKeyExists.Equal(err) { | ||
log.Warnf("[con:%d][schema ver:%d] session error:\n%v\n%s", | ||
log.Warnf("con:%d schema_ver:%d session error:\n%v\n%s", | ||
connID, s.sessionVars.TxnCtx.SchemaVersion, errors.ErrorStack(err), s) | ||
} | ||
return nil, errors.Trace(err) | ||
|
@@ -815,7 +815,7 @@ func (s *session) execute(ctx context.Context, sql string) (recordSets []ast.Rec | |
stmtNodes, err := s.ParseSQL(ctx, sql, charsetInfo, collation) | ||
if err != nil { | ||
s.rollbackOnError(ctx) | ||
log.Warnf("[con:%d] parse error:\n%v\n%s", connID, err, sql) | ||
log.Warnf("con:%d parse error:\n%v\n%s", connID, err, sql) | ||
return nil, errors.Trace(err) | ||
} | ||
metrics.SessionExecuteParseDuration.Observe(time.Since(startTS).Seconds()) | ||
|
@@ -833,7 +833,7 @@ func (s *session) execute(ctx context.Context, sql string) (recordSets []ast.Rec | |
stmt, err := compiler.Compile(ctx, stmtNode) | ||
if err != nil { | ||
s.rollbackOnError(ctx) | ||
log.Warnf("[con:%d] compile error:\n%v\n%s", connID, err, sql) | ||
log.Warnf("con:%d compile error:\n%v\n%s", connID, err, sql) | ||
return nil, errors.Trace(err) | ||
} | ||
metrics.SessionExecuteCompileDuration.Observe(time.Since(startTS).Seconds()) | ||
|
@@ -986,7 +986,7 @@ func (s *session) NewTxn() error { | |
return errors.Trace(err) | ||
} | ||
vars := s.GetSessionVars() | ||
log.Infof("[con:%d][schema ver:%d] NewTxn() inside a transaction auto commit: %d", vars.ConnectionID, vars.TxnCtx.SchemaVersion, txnID) | ||
log.Infof("con:%d[schema ver:%d] NewTxn() inside a transaction auto commit: %d", vars.ConnectionID, vars.TxnCtx.SchemaVersion, txnID) | ||
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. s/ |
||
} | ||
|
||
txn, err := s.store.Begin() | ||
|
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
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.
do we need to keep this format
[con:%d]
?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.
There are places where
con:
is not enclosed by '[]'.How about we should remove all the
[]
that enclosingcon:
?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.
should we more shorter use
c:
instead ofconn:
?and I have a idea: maybe we encapsulation all log method and in
ctx idioms
, in the method body it use prealloc log header in thread load level(e.g."c:123, tx:12, tr:33"
), then need for every place to to fomat conn mannul, and no need to alloc header part every time?