@@ -43,10 +43,6 @@ func (c *Canal) runSyncBinlog() error {
43
43
savePos := false
44
44
force := false
45
45
46
- // The name of the binlog file received in the fake rotate event.
47
- // It must be preserved until the new position is saved.
48
- fakeRotateLogName := ""
49
-
50
46
for {
51
47
ev , err := s .GetEvent (c .ctx )
52
48
if err != nil {
@@ -63,11 +59,16 @@ func (c *Canal) runSyncBinlog() error {
63
59
if ev .Header .LogPos == 0 {
64
60
switch e := ev .Event .(type ) {
65
61
case * replication.RotateEvent :
66
- fakeRotateLogName = string (e .NextLogName )
62
+ fakeRotateLogName : = string (e .NextLogName )
67
63
c .cfg .Logger .Infof ("received fake rotate event, next log name is %s" , e .NextLogName )
64
+ if fakeRotateLogName != c .master .Position ().Name {
65
+ c .cfg .Logger .Info ("log name changed, the fake rotate event will be handled as a real rotate event" )
66
+ } else {
67
+ continue
68
+ }
69
+ default :
70
+ continue
68
71
}
69
-
70
- continue
71
72
}
72
73
73
74
savePos = false
@@ -79,11 +80,6 @@ func (c *Canal) runSyncBinlog() error {
79
80
// next binlog pos
80
81
pos .Pos = ev .Header .LogPos
81
82
82
- // new file name received in the fake rotate event
83
- if fakeRotateLogName != "" {
84
- pos .Name = fakeRotateLogName
85
- }
86
-
87
83
// We only save position with RotateEvent and XIDEvent.
88
84
// For RowsEvent, we can't save the position until meeting XIDEvent
89
85
// which tells the whole transaction is over.
@@ -174,7 +170,6 @@ func (c *Canal) runSyncBinlog() error {
174
170
if savePos {
175
171
c .master .Update (pos )
176
172
c .master .UpdateTimestamp (ev .Header .Timestamp )
177
- fakeRotateLogName = ""
178
173
179
174
if err := c .eventHandler .OnPosSynced (ev .Header , pos , c .master .GTIDSet (), force ); err != nil {
180
175
return errors .Trace (err )
0 commit comments