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) #56887

Merged

Conversation

ti-chi-bot
Copy link
Member

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.1 This PR is cherry-picked to release-7.1 from a source PR. labels Oct 28, 2024
@ti-chi-bot ti-chi-bot bot added do-not-merge/cherry-pick-not-approved cherry-pick-approved Cherry pick PR approved by release team. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed do-not-merge/cherry-pick-not-approved size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 28, 2024
Copy link

ti-chi-bot bot commented Nov 8, 2024

PR needs rebase.

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 kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 8, 2024
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 11, 2024
@joechenrh
Copy link
Contributor

/retest

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-7.1@dbe64fa). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-7.1     #56887   +/-   ##
================================================
  Coverage               ?   73.4862%           
================================================
  Files                  ?       1213           
  Lines                  ?     381851           
  Branches               ?          0           
================================================
  Hits                   ?     280608           
  Misses                 ?      83314           
  Partials               ?      17929           

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 11, 2024
Copy link

ti-chi-bot bot commented Nov 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tangenta, 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:
  • OWNERS [tangenta,wjhuang2016]

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 11, 2024
Copy link

ti-chi-bot bot commented Nov 11, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-11 06:13:01.683931969 +0000 UTC m=+250343.874800965: ☑️ agreed by tangenta.
  • 2024-11-11 07:24:36.759991698 +0000 UTC m=+254638.950860695: ☑️ agreed by wjhuang2016.

@joechenrh
Copy link
Contributor

/retest

@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 12, 2024
@ti-chi-bot ti-chi-bot bot merged commit d36af8f into pingcap:release-7.1 Nov 12, 2024
9 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.1 This PR is cherry-picked to release-7.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants