From 9f9bea84490b331f273e6063e35127028dbc00c7 Mon Sep 17 00:00:00 2001 From: dongmen <20351731+asddongmen@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:11:04 +0800 Subject: [PATCH] binlog: fix binlog filter type (#775) close pingcap/tidb-tools#776 --- pkg/binlog-filter/filter.go | 4 ++-- pkg/binlog-filter/filter_test.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/binlog-filter/filter.go b/pkg/binlog-filter/filter.go index ee7eaff1..5b5116c7 100644 --- a/pkg/binlog-filter/filter.go +++ b/pkg/binlog-filter/filter.go @@ -109,7 +109,7 @@ const ( RemovePartitioning EventType = "remove table partitioning" AddColumn EventType = "add column" SetDefaultValue EventType = "set default value" - RebaseAutoID EventType = "rebase auto_increment ID" + RebaseAutoID EventType = "rebase auto id" AddPrimaryKey EventType = "add primary key" AlterIndexVisibility EventType = "alter index visibility" AlterTTLInfo EventType = "alter ttl info" @@ -248,7 +248,7 @@ func NewBinlogEvent(caseSensitive bool, rules []*BinlogEventRule) (*BinlogEvent, for _, rule := range rules { if err := b.AddRule(rule); err != nil { - log.Error("invalid binlog event rule", zap.Error(err)) + log.Error("invalid binlog event rule", zap.Any("rule", rule), zap.Error(err)) } } diff --git a/pkg/binlog-filter/filter_test.go b/pkg/binlog-filter/filter_test.go index fe73823b..2b040679 100644 --- a/pkg/binlog-filter/filter_test.go +++ b/pkg/binlog-filter/filter_test.go @@ -35,6 +35,7 @@ func (t *testFilterSuite) TestFilter(c *C) { {"xxx_*", "abc_*", []EventType{AllDML, NoneDDL}, nil, nil, Ignore}, {"yyy_*", "abc_*", []EventType{EventType("ALL DML")}, nil, nil, Do}, {"Test_1_*", "abc*", []EventType{"wrong event"}, []string{"^DROP\\s+PROCEDURE", "^CREATE\\s+PROCEDURE"}, nil, Ignore}, + {"cdc", "t1", []EventType{RebaseAutoID}, nil, nil, Ignore}, } cases := []struct { @@ -57,6 +58,7 @@ func (t *testFilterSuite) TestFilter(c *C) { {"yyy_1", "abc_1", InsertEvent, "", Do}, {"yyy_1", "abc_1", CreateIndex, "", Ignore}, {"test_1_a", "abc1", DropView, "", Ignore}, + {"cdc", "t1", RebaseAutoID, "", Ignore}, } // initial binlog event filter @@ -275,6 +277,7 @@ func (t *testFilterSuite) TestToEventType(c *C) { {"add table partition", AddTablePartition, nil}, {"drop taBle partition", DropTablePartition, nil}, {"truncate tablE parTition", TruncateTablePartition, nil}, + {"rebase auto id", RebaseAutoID, nil}, {"xxx", NullEvent, errors.NotValidf("event type %s", "xxx")}, {"I don't know", NullEvent, errors.NotValidf("event type %s", "I don't know")}, } @@ -318,6 +321,7 @@ func (t *testFilterSuite) TestClassifyEvent(c *C) { {AlterTable, ddl, nil}, {AddTablePartition, ddl, nil}, {DropTablePartition, incompatibleDDL, nil}, + {RebaseAutoID, incompatibleDDL, nil}, {TruncateTablePartition, incompatibleDDL, nil}, {"create", NullEvent, errors.NotValidf("event type %s", "create")}, {EventType("xxx"), NullEvent, errors.NotValidf("event type %s", "xxx")},