From 2b6539ee4b2c360ca293c55044978ad59aa308b3 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Wed, 2 Nov 2022 01:16:07 -0400 Subject: [PATCH] Skip binlog events without timestamp to find start timestamp Signed-off-by: Tamal Saha --- internal/databases/mysql/mysql_binlog.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/databases/mysql/mysql_binlog.go b/internal/databases/mysql/mysql_binlog.go index e11152d76..42024a8c6 100644 --- a/internal/databases/mysql/mysql_binlog.go +++ b/internal/databases/mysql/mysql_binlog.go @@ -141,8 +141,12 @@ func GetBinlogStartTimestamp(filename string, flavor string) (time.Time, error) parser.SetFlavor(flavor) parser.SetVerifyChecksum(false) // the faster, the better parser.SetRawMode(true) // choose events to parse manually + err := parser.ParseFile(filename, 0, func(event *replication.BinlogEvent) error { ts = event.Header.Timestamp + if ts == 0 { + return nil // keep reading until first event with timestamp is found + } return fmt.Errorf("shallow file read finished") }) if err != nil && ts == 0 {