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

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-6.5 This PR is cherry-picked to release-6.5 from a source PR. labels May 31, 2024
@ti-chi-bot ti-chi-bot added cherry-pick-approved Cherry pick PR approved by release team. labels May 31, 2024
@ti-chi-bot ti-chi-bot bot added 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 May 31, 2024
@lance6716
Copy link
Contributor

@tangenta please fix the conflict

@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 Jun 7, 2024
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 7, 2024
Copy link

codecov bot commented Jun 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-6.5@d9c5bf6). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-6.5     #53700   +/-   ##
================================================
  Coverage               ?   73.7723%           
================================================
  Files                  ?       1096           
  Lines                  ?     352952           
  Branches               ?          0           
================================================
  Hits                   ?     260381           
  Misses                 ?      75967           
  Partials               ?      16604           

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

ti-chi-bot bot commented Jun 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, tangenta

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

Copy link

ti-chi-bot bot commented Jun 11, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-07 04:00:53.833868127 +0000 UTC m=+91607.887180050: ☑️ agreed by tangenta.
  • 2024-06-11 02:38:18.54392935 +0000 UTC m=+432252.597241273: ☑️ agreed by lance6716.

@ti-chi-bot ti-chi-bot bot merged commit 956e83d into pingcap:release-6.5 Jun 11, 2024
10 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-6.5 This PR is cherry-picked to release-6.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants