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

planner: support the safe-update mode #20184

Closed
wants to merge 5 commits into from

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented Sep 23, 2020

What problem does this PR solve?

Issue Number: close #20177

Problem Summary: support the safe-update mode

What is changed and how it works?

Please see #20177 for more details.

Check List

Tests

  • Unit test

Release note

  • planner: support the safe-update mode

@qw4990 qw4990 requested review from zz-jason and eurekaka September 23, 2020 12:20
@qw4990 qw4990 requested review from a team as code owners September 23, 2020 12:20
@github-actions github-actions bot added the sig/execution SIG execution label Sep 23, 2020
@winoros
Copy link
Member

winoros commented Sep 23, 2020

We should adjust the doc together?


safeUpdatesErr := func(err error) {
c.Assert(err, Not(IsNil))
c.Assert(err.Error(), Equals, "[planner:1175]You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column")
Copy link
Member

Choose a reason for hiding this comment

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

Could we just compare with ErrUpdateWithoutKeyInSafeMode?

@@ -759,9 +772,29 @@ func (ds *DataSource) findBestTask(prop *property.PhysicalProperty, planCounter
}
}

if safeUpdateMode && numRangeScanPlans == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Should we just check the best plan instead of every plan? The range scan plan may not be chosen as the chosen one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the optimizer chooses a full-scan as the best plan, but actually some other range-scans can be used, we shouldn't return the error in this case.

Copy link
Member

@wjhuang2016 wjhuang2016 left a comment

Choose a reason for hiding this comment

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

Need to check:

  1. explain statements don't report an error.
  2. statements with a limit clause don't report an error.
  3. multiple-table deletes and updates.

@@ -447,6 +447,9 @@ const (

// TiDBEnableAmendPessimisticTxn indicates if amend pessimistic transactions is enabled.
TiDBEnableAmendPessimisticTxn = "tidb_enable_amend_pessimistic_txn"

// TiDBEnableSafeUpdates indicates if the safe-update mode is enabled.
TiDBEnableSafeUpdates = "tidb_enable_safe_updates"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we just use sql_safe_updates?

@github-actions github-actions bot added the sig/sql-infra SIG: SQL Infra label Jan 7, 2021
@ti-chi-bot
Copy link
Member

@qw4990: PR needs rebase.

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 kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 23, 2021
@qw4990 qw4990 closed this May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. sig/execution SIG execution sig/sql-infra SIG: SQL Infra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support sql_safe_updates variable
5 participants