-
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
planner,executor: fix 'select ...(join on partition table) for update' panic (#21148) #25845
Conversation
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
[REVIEW NOTIFICATION] This pull request has not been approved. 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. |
/run-all-tests |
@tiancaiamao you're already a collaborator in bot's repo. |
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.
ci need to be fixed
Done @XuHuaiyu |
cherry-pick #21148 to release-5.0
You can switch your code base to this Pull Request by using git-extras:
# In tidb repo: git pr https://github.com/pingcap/tidb/pull/25845
After apply modifications, you can push your change to this PR via:
What problem does this PR solve?
Issue Number: close #20028
Problem Summary:
'select ... for update' need the table ID to construct the lock key.
When this SQL works on a partitioned table, the table ID should be partition ID.
So how to get that partition ID?
In http://github.com/pingcap/tidb/pull/14921 I try to avoid column pruning of the partition columns,
so we can get the partition column data, and then use it to calculate the partition to get the ID.
That fix works on a single table, but not the joining of tables.
What is changed and how it works?
What's Changed:
In the logical plan phase, if
buildSelectLock
find itself works on partitioned tables,change the schema add an extra partition ID column to the DataSource.
Some tiny changes in the column pruning step to get the correct schema.
In the TableReader executor, fill the extra partition ID column in the chunk row.
In the SelectLockExec, use the partition ID from the chunk row, to construct the correct lock key.
How it Works:
Let the table reader return an extra column with partition ID, so the
SelectLockExec can use that partition ID to construct the lock key.
Related changes
Check List
Tests
Release note