Skip to content

Fix bug for ingesting data to a "pk is handle" table (#2125)#2127

Merged
JaySon-Huang merged 1 commit intopingcap:release-4.0from
ti-srebot:release-4.0-46b829485358
Jun 17, 2021
Merged

Fix bug for ingesting data to a "pk is handle" table (#2125)#2127
JaySon-Huang merged 1 commit intopingcap:release-4.0from
ti-srebot:release-4.0-46b829485358

Conversation

@ti-srebot
Copy link
Collaborator

@ti-srebot ti-srebot commented Jun 10, 2021

cherry-pick #2125 to release-4.0
You can switch your code base to this Pull Request by using git-extras:

# In tics repo:
git pr https://github.com/pingcap/tics/pull/2127

After apply modifications, you can push your change to this PR via:

git push git@github.com:ti-srebot/tics.git pr/2127:release-4.0-46b829485358

What problem does this PR solve?

Issue Number: close #2118

Problem Summary:

DeltaTree add a "_tidb_rowid" column to the table even if "pk is handle" is true. We use the FunctionToInt64 to copy data from the primary key column to the handle column under this situation.

https://github.com/pingcap/tics/blob/1078d0b8199a1cfe54d73623ea8da636505f419b/dbms/src/Storages/DeltaMerge/DeltaMergeStore.cpp#L403-L410

However, if the types are identical, FunctionToInt64 only does a shallow copy and makes the primary key column and _tidb_rowid share the same column ptr when "pk is handle".

https://github.com/pingcap/tics/blob/1078d0b8199a1cfe54d73623ea8da636505f419b/dbms/src/Functions/FunctionsConversion.h#L832-L841

After that, we need to reorganize the boundary of blocks, this makes us append some rows into the pk column and handle column. Unfortunately, they share the same column pointer, which makes the columns inside one block don't align and make trouble for later processing.
https://github.com/pingcap/tics/blob/1078d0b8199a1cfe54d73623ea8da636505f419b/dbms/src/Storages/DeltaMerge/PKSquashingBlockInputStream.h#L75-L99

What is changed and how it works?

Use deep copy instead of shallow copy when the types are identical in DeltaMergeStore::addExtraColumnIfNeed.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch:

Check List

Tests

  • Unit test

Side effects

Release note

  • No release note

@ti-srebot ti-srebot added CHERRY-PICK cherry pick priority/release-blocker This issue blocks a release. Please solve it ASAP. status/LGT1 Indicates that a PR has LGTM 1. labels Jun 10, 2021
@ti-srebot ti-srebot added the type/bugfix This PR fixes a bug. label Jun 10, 2021
@ti-srebot ti-srebot requested a review from flowbehappy June 10, 2021 05:35
@ti-srebot ti-srebot added this to the v4.0.14 milestone Jun 10, 2021
@JaySon-Huang JaySon-Huang removed priority/release-blocker This issue blocks a release. Please solve it ASAP. status/LGT1 Indicates that a PR has LGTM 1. labels Jun 10, 2021
@JaySon-Huang JaySon-Huang changed the title Fix bug for ingesting data to a "pk is handle" table (#2125) [DNM] Fix bug for ingesting data to a "pk is handle" table (#2125) Jun 10, 2021
@SchrodingerZhu
Copy link
Contributor

/rebuild

@JaySon-Huang JaySon-Huang force-pushed the release-4.0-46b829485358 branch from 1a0a1b4 to 3fbdf73 Compare June 11, 2021 17:30
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@JaySon-Huang JaySon-Huang force-pushed the release-4.0-46b829485358 branch from 3fbdf73 to 6e926e4 Compare June 11, 2021 17:36
@JaySon-Huang JaySon-Huang changed the title [DNM] Fix bug for ingesting data to a "pk is handle" table (#2125) Fix bug for ingesting data to a "pk is handle" table (#2125) Jun 11, 2021
@JaySon-Huang
Copy link
Contributor

/run-all-tests

Copy link
Contributor

@flowbehappy flowbehappy 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 the status/LGT1 Indicates that a PR has LGTM 1. label Jun 16, 2021
@JaySon-Huang JaySon-Huang merged commit 8491e3e into pingcap:release-4.0 Jun 17, 2021
@JaySon-Huang JaySon-Huang deleted the release-4.0-46b829485358 branch June 17, 2021 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CHERRY-PICK cherry pick status/LGT1 Indicates that a PR has LGTM 1. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants