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

*: fix the origin_default_value issue in disaggregated mode #9666

Merged
merged 7 commits into from
Nov 25, 2024

Conversation

zimulala
Copy link
Contributor

@zimulala zimulala commented Nov 22, 2024

What problem does this PR solve?

Issue Number: close #9665

Problem Summary:

What is changed and how it works?

Since the TiDB add new column operation does not actually write the new column data, it simply logs it to `origin_default_value`.
In disaggregated mode, the default value may be read using tipb passing the default value. The original logic is to pass the default value of tipb to the default value of ColumnInfo (calling defaultValueToField).

After obtaining the default value of tipb, decode it, and then use the defaultValueToField value for processing.

Check List

Tests

  • Unit test
  • Integration test
tidb> set session tidb_isolation_read_engines='tiflash';
tidb> select col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12, col13, col14, hex(col15) from test.t;

Before this PR:

+------+------+------+------+------+-------+------+------+------+-------+-------+-------+----------+----------+-------+
| col1 | col2 | col3 | col4 | col5 | col6  | col7 | col8 | col9 | col10 | col11 | col12 | col13    | col14    |col15 |
+------+------+------+------+------+-------+------+------+------+-------+-------+-------+----------+----------+-------+
|    0 | 0000 | 0.00 | 0.00 |    0 | sss | NULL | NULL | 0000 |       |       | NULL  | 00:00:00 | 00:00:00 | NULL  |
|    0 | 0000 | 0.00 | 0.00 |    0 | sss | NULL | NULL | 0000 |       |       | NULL  | 00:00:00 | 00:00:00 | NULL  |
|    0 | 0000 | 0.00 | 0.00 |    0 | sss | NULL | NULL | 0000 |       |       | NULL  | 00:00:00 | 00:00:00 | NULL  |
+------+------+------+------+------+-------+------+------+------+-------+-------+-------+----------+----------+-------+

After this PR:

+------+------+------+------+------+------+---------------------+---------------------+------+--------+--------+---------------------+----------+-------+------------+
| col1 | col2 | col3 | col4 | col5 | col6 | col7                | col8                | col9 | col10  | col11  | col12               | col13    | col14 | hex(col15) |
+------+------+------+------+------+------+---------------------+---------------------+------+--------+--------+---------------------+----------+-------+------------+
|   30 | 0000 | 0.00 | 1.23 |  123 | sss  | 2017-02-11 00:00:00 | 2018-11-04 23:12:03 | 2012 | value3 | value1 | 2018-11-04 23:12:03 | 12:18:30 | NULL  | 10203      |
|   30 | 0000 | 0.00 | 1.23 |  123 | sss  | 2017-02-11 00:00:00 | 2018-11-04 23:12:03 | 2012 | value3 | value1 | 2018-11-04 23:12:03 | 12:18:30 | NULL  | 10203      |
|   30 | 0000 | 0.00 | 1.23 |  123 | sss  | 2017-02-11 00:00:00 | 2018-11-04 23:12:03 | 2012 | value3 | value1 | 2018-11-04 23:12:03 | 12:18:30 | NULL  | 10203      |
+------+------+------+------+------+------+---------------------+---------------------+------+--------+--------+---------------------+----------+-------+------------+
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Fix the bug that in the disaggregated storage and compute architecture, the query result of added column is not correct

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. labels Nov 22, 2024
@sre-bot
Copy link
Collaborator

sre-bot commented Nov 22, 2024

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 22, 2024
@zimulala zimulala changed the title [DNM]*: fix the origin_default_value issue in disaggregated mode *: fix the origin_default_value issue in disaggregated mode Nov 22, 2024
@zimulala
Copy link
Contributor Author

PTAL @Lloyd-Pottiger

dbms/src/TiDB/Schema/TiDB.cpp Outdated Show resolved Hide resolved
dbms/src/TiDB/Schema/TiDB.cpp Outdated Show resolved Hide resolved
dbms/src/TiDB/Schema/TiDB.cpp Outdated Show resolved Hide resolved
dbms/src/TiDB/Schema/TiDB.cpp Outdated Show resolved Hide resolved
Comment on lines +1442 to +1447
if (val.get<Int64>() == 0)
{
Poco::Dynamic::Var empty_val;
tidb_column_info.origin_default_value = empty_val;
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

set tidb_column_info.origin_default_value = tipb_column_info.default_val(); if val.get<Int64>() != 0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. If we don't do this, after alter table t add column col2 year not null;, we get this data is 2000 not 0000.

@zimulala
Copy link
Contributor Author

PTAL @Lloyd-Pottiger

Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger 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-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 22, 2024
@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Nov 25, 2024
Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

ti-chi-bot bot commented Nov 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, Lloyd-Pottiger

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [JaySon-Huang,Lloyd-Pottiger]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 25, 2024
Copy link
Contributor

ti-chi-bot bot commented Nov 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-22 08:10:21.654749461 +0000 UTC m=+192009.274403977: ☑️ agreed by Lloyd-Pottiger.
  • 2024-11-25 09:36:34.430402402 +0000 UTC m=+456382.050056918: ☑️ agreed by JaySon-Huang.

@zimulala zimulala force-pushed the zimuxia/add-col-default branch from 0c22cb5 to a81900b Compare November 25, 2024 10:27
Copy link
Contributor

ti-chi-bot bot commented Nov 25, 2024

@zimulala: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

trigger some heavy tests which will not run always when PR updated.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot merged commit e3e6780 into pingcap:master Nov 25, 2024
5 checks passed
@zimulala zimulala deleted the zimuxia/add-col-default branch November 26, 2024 02:23
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Nov 28, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #9683.

ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request Nov 28, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Dec 3, 2024
…#9683)

close #9665

Since the TiDB add new column operation does not actually write the new column data, it simply logs it to `origin_default_value`.
In disaggregated mode, the default value may be read using tipb passing the default value. The original logic is to pass the default value of tipb to the default value of ColumnInfo (calling defaultValueToField).

After obtaining the default value of tipb, decode it, and then use the defaultValueToField value for processing.

Signed-off-by: JaySon-Huang <[email protected]>

Co-authored-by: JaySon-Huang <[email protected]>
Co-authored-by: JaySon <[email protected]>
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Dec 11, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request Dec 11, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #9719.

ti-chi-bot bot added a commit that referenced this pull request Dec 11, 2024
…#9719)

close #9665

Since the TiDB add new column operation does not actually write the new column data, it simply logs it to `origin_default_value`.
In disaggregated mode, the default value may be read using tipb passing the default value. The original logic is to pass the default value of tipb to the default value of ColumnInfo (calling defaultValueToField).

After obtaining the default value of tipb, decode it, and then use the defaultValueToField value for processing.

Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: JaySon-Huang <[email protected]>

Co-authored-by: Lynn <[email protected]>
Co-authored-by: JaySon-Huang <[email protected]>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Dec 13, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #9729.

ti-chi-bot bot pushed a commit that referenced this pull request Dec 20, 2024
…#9729)

close #9665

Since the TiDB add new column operation does not actually write the new column data, it simply logs it to `origin_default_value`.
In disaggregated mode, the default value may be read using tipb passing the default value. The original logic is to pass the default value of tipb to the default value of ColumnInfo (calling defaultValueToField).

After obtaining the default value of tipb, decode it, and then use the defaultValueToField value for processing.

Co-authored-by: Lynn <[email protected]>
Co-authored-by: Lloyd-Pottiger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
5 participants