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

charset: fix incorrect result when querying in-txn updates when new collation is enabled #18703

Merged
merged 2 commits into from
Jul 21, 2020

Conversation

bb7133
Copy link
Member

@bb7133 bb7133 commented Jul 21, 2020

What problem does this PR solve?

Issue Number: close #18702

Problem Summary:

In TiDB, an uncommitted update within an ongoing transaction is saved in a memory buffer. When read by the ongoing transaction, the value in the memory buffer is supposed to be returned. However, for a column with new collation(when the config new_collations_enabled_on_first_bootstrap is set to true) and the ongoing transaction is reading the uncommitted update with a unique index, the value is wrongly decoded. As a result, the uncommitted update is not included in the result and thus causes the bug.

What is changed and how it works?

What's Changed and how it works:

The DecodeIndexHandle is used to decode the handle from the index value in the memory buffer, fix it by adding support for the new collation:

handle, err := tablecodec.DecodeIndexHandle(key, value, len(m.index.Columns), pkTp)

Check List

Tests

Side effects

Release note

  • Fix the issue that incorrect result is returned when querying in-txn updates when new collation is enabled

@coocood
Copy link
Member

coocood commented Jul 21, 2020

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 21, 2020
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.

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 21, 2020
Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot removed the status/LGT2 Indicates that a PR has LGTM 2. label Jul 21, 2020
@ti-srebot ti-srebot added the status/LGT3 The PR has already had 3 LGTM. label Jul 21, 2020
@crazycs520
Copy link
Contributor

/run-all-tests

Copy link
Contributor

@bobotu bobotu left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot
Copy link
Contributor

@bobotu,Thanks for your review. However, LGTM is restricted to Reviewers or higher roles.See the corresponding SIG page for more information. Related SIGs: ddl(slack),execution(slack).

@bb7133
Copy link
Member Author

bb7133 commented Jul 21, 2020

/run-all-tests

@jebter
Copy link

jebter commented Jul 21, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 21, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@bb7133 merge failed.

@jebter
Copy link

jebter commented Jul 21, 2020

/run-integration-copr-test

@bb7133
Copy link
Member Author

bb7133 commented Jul 21, 2020

/run-check_dev

@jebter jebter merged commit 187271d into pingcap:release-4.0 Jul 21, 2020
@bb7133 bb7133 changed the title charset: fix incorrect result when querying in-txn updates when new c… charset: fix incorrect result when querying in-txn updates when new collation is enabled Jul 24, 2020
gregwebs added a commit to gregwebs/tidb that referenced this pull request Sep 1, 2020
The decoding status can be tracked by the type system.
This can help prevent bugs such as the one fixed here:
pingcap#18703
@bb7133 bb7133 deleted the bb7133/fix_idx_collation branch December 29, 2023 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/charset component/expression require-LGT3 Indicates that the PR requires three LGTM. status/can-merge Indicates a PR has been approved by a committer. status/LGT3 The PR has already had 3 LGTM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants