|
@@ -157,15 +157,20 @@ func getBinlogNamePosition() (fileName string, position uint32, err error) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 如果从表中没有取到数据,则从mysql中获取,则从 MySQL 中获取最新的文件名和位置。
|
|
|
- if fileName == `` || position == 0 {
|
|
|
- item, tmpErr := binlog.GetShowMaster()
|
|
|
- if tmpErr != nil {
|
|
|
- err = tmpErr
|
|
|
- return
|
|
|
- }
|
|
|
- fileName = item.File
|
|
|
- position = item.Position
|
|
|
+ // 从mysql中获取最新的binlog文件名称和位置,名称不一致则以mysql中为准
|
|
|
+ item, tmpErr := binlog.GetShowMaster()
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ dbFileName := item.File
|
|
|
+ dbPosition := item.Position
|
|
|
+ if fileName != dbFileName {
|
|
|
+ fileName = dbFileName
|
|
|
+ position = dbPosition
|
|
|
+ }
|
|
|
+ if position == 0 {
|
|
|
+ position = dbPosition
|
|
|
}
|
|
|
|
|
|
return
|