Skip to content

Commit

Permalink
binlog-filter: log error instead of return (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD committed Feb 26, 2024
1 parent beb8d92 commit 627e9c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/binlog-filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -170,7 +172,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))
}
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/binlog-filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 627e9c9

Please sign in to comment.