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

executor: sync deletable columns to binlog when remove record (#53617) #53647

Merged

Conversation

ti-chi-bot
Copy link
Member

@ti-chi-bot ti-chi-bot commented May 29, 2024

This is an automated cherry-pick of #53617

What problem does this PR solve?

Issue Number: close #53133

Problem Summary:

Previously, when TiDB writes delete records to binlog, column count of schema and data mismatch. This is because only public columns are selected, while data includes all deletable columns.

What changed and how does it work?

Make schema use all deletable columns.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    1. deploy two TiDB clusters, and start pump & drainer.
    2. modify upstream TiDB code:
    diff --git a/pkg/config/config.toml.example b/pkg/config/config.toml.example
    index c1438a9e85..b73828367d 100644
    --- a/pkg/config/config.toml.example
    +++ b/pkg/config/config.toml.example
    @@ -416,7 +416,7 @@ capacity-mb = 1000.0
     # enable to write binlog.
     # NOTE: If binlog is enabled with Kafka (e.g. arbiter cluster),
     # txn-total-size-limit should be less than 1073741824(1G) because this is the maximum size that can be handled by Kafka.
    -enable = false
    +enable = true
     
     # WriteTimeout specifies how long it will wait for writing binlog to pump.
     write-timeout = "15s"
    diff --git a/pkg/ddl/column.go b/pkg/ddl/column.go
    index 206b64d513..1727ba4c44 100644
    --- a/pkg/ddl/column.go
    +++ b/pkg/ddl/column.go
    @@ -173,6 +173,7 @@ func onAddColumn(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, err error)
                    // reorganization -> public
                    // Adjust table column offset.
                    failpoint.InjectCall("onAddColumnStateWriteReorg")
    +               time.Sleep(20 * time.Second)
                    offset, err := LocateOffsetToMove(columnInfo.Offset, pos, tblInfo)
                    if err != nil {
                            return ver, errors.Trace(err)
    1. execute SQL at upstream:
    -- session 1
    CREATE TABLE `t` (
      `a` int(11) DEFAULT NULL,
      `b` int(11) DEFAULT NULL,
      `c` int(11) DEFAULT NULL,
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
    insert into t values (1, 1, 1), (2, 2, 2), (3, 3, 3);
    alter table t add column d int default 3;
    
    -- session 2
    delete from t where a = 1;
    
    1. execute SQL at downstream:
    mysql> select * from t;
    +------+------+------+------+
    | a    | b    | c    | d    |
    +------+------+------+------+
    |    3 |    3 |    3 |    3 |
    |    2 |    2 |    2 |    3 |
    +------+------+------+------+
    2 rows in set (0.00 sec)
    
    Even if we synchronize a 4-columns row to binlog, drainer can handle it correctly by decoding necessary(public) columns:
    https://github.com/pingcap/tidb-binlog/blob/6fba4f883a0c6c7e0d68b3b8aef1a53d9454b273/drainer/translator/mysql.go#L88-L90
  • No need to test
    • I checked and no code files have been changed.

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

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. labels May 29, 2024
@ti-chi-bot ti-chi-bot added cherry-pick-approved Cherry pick PR approved by release team. labels May 29, 2024
Copy link
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

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

please fix conflicts

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label May 29, 2024
Copy link

ti-chi-bot bot commented May 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, wjhuang2016

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:

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 approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 29, 2024
Copy link

ti-chi-bot bot commented May 29, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-29 07:02:59.851246042 +0000 UTC m=+2846333.608381615: ☑️ agreed by D3Hunter.
  • 2024-05-29 07:14:40.777035891 +0000 UTC m=+2847034.534171456: ☑️ agreed by wjhuang2016.

@tangenta
Copy link
Contributor

/retest

1 similar comment
@tangenta
Copy link
Contributor

/retest

@tangenta
Copy link
Contributor

Encounter flaky test #52791

@tangenta
Copy link
Contributor

/retest

Copy link

codecov bot commented May 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-7.5@5c6ee34). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-7.5     #53647   +/-   ##
================================================
  Coverage               ?   72.0210%           
================================================
  Files                  ?       1411           
  Lines                  ?     410669           
  Branches               ?          0           
================================================
  Hits                   ?     295768           
  Misses                 ?      94994           
  Partials               ?      19907           
Flag Coverage Δ
unit 72.0210% <100.0000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9913% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 53.4686% <0.0000%> (?)

@ti-chi-bot ti-chi-bot bot merged commit f3b0a90 into pingcap:release-7.5 May 29, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants