@@ -10,6 +10,7 @@ import (
1010"github.com/ngaut/log"
1111"github.com/siddontang/go-mysql/mysql"
1212"github.com/siddontang/go-mysql/replication"
13+ "github.com/siddontang/go-mysql/schema"
1314)
1415
1516var (
@@ -62,7 +63,9 @@ func (c *Canal) startSyncBinlog() error {
6263log .Infof ("rotate binlog to %v" , pos )
6364case * replication.RowsEvent :
6465// we only focus row based event
65- if err = c .handleRowsEvent (ev ); err != nil {
66+ err = c .handleRowsEvent (ev )
67+ if err != nil && errors .Cause (err ) != schema .ErrTableNotExist {
68+ // We can ignore table not exist error
6669log .Errorf ("handle rows event error %v" , err )
6770return errors .Trace (err )
6871}
@@ -119,21 +122,18 @@ func (c *Canal) handleRowsEvent(e *replication.BinlogEvent) error {
119122return c .travelRowsEventHandler (events )
120123}
121124
122- func (c * Canal ) WaitUntilPos (pos mysql.Position , timeout int ) error {
123- if timeout <= 0 {
124- timeout = 60
125- }
126-
127- timer := time .NewTimer (time .Duration (timeout ) * time .Second )
125+ func (c * Canal ) WaitUntilPos (pos mysql.Position , timeout time.Duration ) error {
126+ timer := time .NewTimer (timeout )
128127for {
129128select {
130129case <- timer .C :
131- return errors .Errorf ("wait position %v err " , pos )
130+ return errors .Errorf ("wait position %v too long > %s " , pos , timeout )
132131default :
133- curpos := c .master .Pos ()
134- if curpos .Compare (pos ) >= 0 {
132+ curPos := c .master .Pos ()
133+ if curPos .Compare (pos ) >= 0 {
135134return nil
136135} else {
136+ log .Debugf ("master pos is %v, wait catching %v" , curPos , pos )
137137time .Sleep (100 * time .Millisecond )
138138}
139139}
@@ -142,7 +142,7 @@ func (c *Canal) WaitUntilPos(pos mysql.Position, timeout int) error {
142142return nil
143143}
144144
145- func (c * Canal ) CatchMasterPos (timeout int ) error {
145+ func (c * Canal ) CatchMasterPos (timeout time. Duration ) error {
146146rr , err := c .Execute ("SHOW MASTER STATUS" )
147147if err != nil {
148148return errors .Trace (err )
0 commit comments