Skip to content

Commit 4ca90cd

Browse files
committed
canal: remove ErrHandleInterrupted
1 parent 3ca161f commit 4ca90cd

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

canal/handler.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
package canal
22

3-
import (
4-
"github.com/juju/errors"
5-
"github.com/ngaut/log"
6-
"github.com/siddontang/go-mysql/mysql"
7-
)
8-
9-
var (
10-
ErrHandleInterrupted = errors.New("do handler error, interrupted")
11-
)
3+
import "github.com/juju/errors"
124

135
type RowsEventHandler interface {
14-
// Handle RowsEvent, if return ErrHandleInterrupted, canal will
6+
// Handle RowsEvent, if return error, canal will
157
// stop the sync
168
Do(e *RowsEvent) error
179
String() string
@@ -29,13 +21,9 @@ func (c *Canal) travelRowsEventHandler(e *RowsEvent) error {
2921

3022
var err error
3123
for _, h := range c.rsHandlers {
32-
if err = h.Do(e); err != nil && !mysql.ErrorEqual(err, ErrHandleInterrupted) {
33-
log.Errorf("handle %v err: %v", h, err)
34-
} else if mysql.ErrorEqual(err, ErrHandleInterrupted) {
35-
log.Errorf("handle %v err, interrupted", h)
36-
return ErrHandleInterrupted
24+
if err = h.Do(e); err != nil {
25+
return errors.Trace(err)
3726
}
38-
3927
}
4028
return nil
4129
}

canal/sync.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func (c *Canal) startSyncBinlog() error {
4545

4646
timeout = time.Second
4747

48+
curPos := pos.Pos
4849
//next binlog pos
4950
pos.Pos = ev.Header.LogPos
5051

@@ -66,7 +67,7 @@ func (c *Canal) startSyncBinlog() error {
6667
err = c.handleRowsEvent(ev)
6768
if err != nil && errors.Cause(err) != schema.ErrTableNotExist {
6869
// We can ignore table not exist error
69-
log.Errorf("handle rows event error %v", err)
70+
log.Errorf("handle rows event at (%s, %d) error %v", pos.Name, curPos, err)
7071
return errors.Trace(err)
7172
}
7273
continue

0 commit comments

Comments
 (0)