diff --git a/pkg/binlog-filter/filter.go b/pkg/binlog-filter/filter.go index 8f66d25f..a4e38aa8 100644 --- a/pkg/binlog-filter/filter.go +++ b/pkg/binlog-filter/filter.go @@ -18,7 +18,9 @@ import ( "strings" "github.com/pingcap/errors" + "github.com/pingcap/log" selector "github.com/pingcap/tidb-tools/pkg/table-rule-selector" + "go.uber.org/zap" ) // ActionType indicates how to handle matched items @@ -216,7 +218,7 @@ func NewBinlogEvent(caseSensitive bool, rules []*BinlogEventRule) (*BinlogEvent, for _, rule := range rules { if err := b.AddRule(rule); err != nil { - return nil, errors.Annotatef(err, "initial rule %+v in binlog event filter", rule) + log.Error("invalid binlog event rule", zap.Error(err)) } } diff --git a/pkg/binlog-filter/filter_test.go b/pkg/binlog-filter/filter_test.go index 55e564c4..fe73823b 100644 --- a/pkg/binlog-filter/filter_test.go +++ b/pkg/binlog-filter/filter_test.go @@ -34,6 +34,7 @@ func (t *testFilterSuite) TestFilter(c *C) { {"Test_1_*", "abc*", []EventType{DeleteEvent, InsertEvent, CreateIndex, DropIndex, DropView}, []string{"^DROP\\s+PROCEDURE", "^CREATE\\s+PROCEDURE"}, nil, Ignore}, {"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}, } cases := []struct { @@ -77,6 +78,7 @@ func (t *testFilterSuite) TestFilter(c *C) { rules[0].Events = []EventType{} rules[1].Action = Do rules[2].Events = []EventType{"ALL DDL"} + rules = rules[:3] for _, rule := range rules { err = filter.UpdateRule(rule) c.Assert(err, IsNil)