-
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
ddl, executor: add warning log for lock/unlock tables #29301
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
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. |
/cc @morgo |
executor/ddl.go
Outdated
func (e *DDLExec) executeUnlockTables(_ *ast.UnlockTablesStmt) error { | ||
if !config.TableLockEnabled() { | ||
e.ctx.GetSessionVars().StmtCtx.AppendWarning(errors.Errorf("Unlock tables works only when enable-table-lock is set in config file")) | ||
return nil | ||
} |
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.
A couple of suggestions:
- We make the mode dependent on https://docs.pingcap.com/tidb/dev/system-variables#tidb_enable_noop_functions-new-in-v40 -- but it only ever returns warnings at most (since it's important DDL can restore). This provides a mechanism for users to kill the warning if that is problematic for their script.
- We add a new error number / error code. This helps us track the errors in information schema so we know which unsupported syntax the user is encountering.
Let me know what you think about either. These are just suggestions.
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.
- Sounds good for me.
- Maybe we can use
mysql.ErrNotSupportedYet
with different error message betweenErrFunctionsNoopImpl
.
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.
Sounds good to me.
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.
Done,PTAL @morgo
executor/ddl.go
Outdated
if noopFuncsMode == variable.OffInt { | ||
return err | ||
} else if noopFuncsMode == variable.WarnInt { | ||
e.ctx.GetSessionVars().StmtCtx.AppendWarning(err) | ||
} | ||
return nil |
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.
Sorry, for this syntax I think we can only WARN
at most. I know this is different from most other noop functions, but this syntax is used by mysqldump
. If we generate an error, mysqldump files won't restore by default :(
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.
The behavior will be very strange. If we only have WARN
, I think use TableLockEnabled()
to control it is better than noopFuncsMode
. What's your opinion? @morgo
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 agree it is strange, but the change is too severe if mysqldump can not be restored.
For the docs: https://docs.pingcap.com/tidb/dev/system-variables#tidb_enable_noop_functions-new-in-v40
We can add a sentence: Setting tidb_enable_noop_functions
to OFF
does not prevent LOCK TABLE t1 WRITE
from executing. A warning is returned instead. This behavior is required for compatibility with mysqldump.
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.
Updated, PTAL @morgo
executor/errors.go
Outdated
@@ -64,6 +64,7 @@ var ( | |||
ErrNotSupportedWithSem = dbterror.ClassOptimizer.NewStd(mysql.ErrNotSupportedWithSem) | |||
ErrPluginIsNotLoaded = dbterror.ClassExecutor.NewStd(mysql.ErrPluginIsNotLoaded) | |||
ErrSetPasswordAuthPlugin = dbterror.ClassExecutor.NewStd(mysql.ErrSetPasswordAuthPlugin) | |||
ErrFuncNotEnabled = dbterror.ClassExecutor.NewStdErr(mysql.ErrNotSupportedYet, parser_mysql.Message("%-.32s works only when %-.32s is set in config file", nil)) |
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.
The warning is not clear that the behavior is a noop. This distinction is important in understanding the risks. May I suggest instead:
LOCK TABLE is not supported. To enable this experimental feature, set 'enable-table-lock' in the configuration file.
Otherwise LGTM. I think it is too confusing to say that it is also affected by tidb_enable_noop_funcs = ON, so we can handle that in docs.
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, it's too confusing. I think we should return warning whether noop_funcs
enabled or not. Maybe controlled by enable-table-lock
is enough. @morgo
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.
/cc @AilinKid |
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.
LGTM, thanks for making edits!
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 18dd8d0
|
/run-cherry-picker |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.3 in PR #29437 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.1 in PR #29439 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.2 in PR #29440 |
What problem does this PR solve?
Issue Number: close #28967
Problem Summary: Add warning log for
lock tables
andunlock tables
whenenable-table-lock
flag not enabled.What is changed and how it works?
Check List
Tests
Release note