*: fix a bug that update statement uses point get and update plan with different tblInfo (#54183) #57077
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.
This is an automated cherry-pick of #54183
What problem does this PR solve?
Issue Number: close #53634
Problem Summary:
Case
Init SQLs:
prepare statements:
run a statement:
begin;
do DDL:
When the DDL is in Write-Only state
exec statements:
Step4. using conn1
Check the result
select * from stock;
Statement execution order table
Conclusion
The update statement in step3 uses point get and update plan, but the tblInfo used by the two plans is inconsistent, resulting in incorrect data in real storage.
After executing step3. select statement, the stock is locked in
GetRelatedTableForMDL
, sostmt.tbls[i].Meta().Revision != newTbl.Meta().Revision
is false. It meansschemaNotMatch
is false. So we needn't toPreprocess
.tidb/pkg/planner/core/plan_cache.go
Lines 114 to 119 in d5b89f8
Step3. update statement using
tblName.TableInfo
(get it when preparing statements,cct_1
is public) innewPointGetPlan
.tidb/pkg/planner/core/point_get_plan.go
Line 1317 in d5b89f8
Step3. update statement using
t
gets fromis.TableByID(tbl.ID)
(cct_1
is write-only)tidb/pkg/planner/core/point_get_plan.go
Lines 1945 to 1950 in d5b89f8
What changed and how does it work?
Add the
Revision
field comparison oftbl
(get from txn infoschema) andnewTbl
to confirm whether reprocess is required.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.