Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: log more debug info for getBinlogCoordinateByTs (#1926)

Yilong Li6c8766e8dceb
diff --git a/plugin/db/mysql/restore.go b/plugin/db/mysql/restore.go
index 3521d817c8..e1de9ed518 100644
--- a/plugin/db/mysql/restore.go
+++ b/plugin/db/mysql/restore.go
@@ -308,8 +308,10 @@ func (driver *Driver) GetLatestBackupBeforeOrEqualTs(ctx context.Context, backup
targetBinlogCoordinate, err := driver.getBinlogCoordinateByTs(ctx, targetTs)
if err != nil {
+ log.Error("Failed to get binlog coordinate by targetTs", zap.Int64("targetTs", targetTs), zap.Error(err))
return nil, fmt.Errorf("failed to get binlog coordinate by targetTs %d, error: %w", targetTs, err)
}
+ log.Debug("Got binlog coordinate by targetTs", zap.Int64("targetTs", targetTs), zap.Any("binlogCoordinate", *targetBinlogCoordinate))
var validBackupList []*api.Backup
for _, b := range backupList {
@@ -694,6 +696,7 @@ func (driver *Driver) getBinlogCoordinateByTs(ctx context.Context, targetTs int6
if err != nil {
return nil, fmt.Errorf("failed to parse the local binlog file %q's first binlog event ts, error: %w", file.Name, err)
}
+ log.Debug("Parsed first binlog event ts", zap.String("file", file.Name), zap.Int64("eventTs", eventTs))
if eventTs >= targetTs {
if i == 0 {
return nil, fmt.Errorf("the targetTs %d is before the first event ts %d of the oldest binlog file %q", targetTs, eventTs, file.Name)
@@ -711,6 +714,7 @@ func (driver *Driver) getBinlogCoordinateByTs(ctx context.Context, targetTs int6
isLastBinlogFile = true
binlogFileTarget = &binlogFilesLocalSorted[len(binlogFilesLocalSorted)-1]
}
+ log.Debug("Found potential binlog file containing targetTs", zap.String("binlogFile", binlogFileTarget.Name), zap.Int64("targetTs", targetTs), zap.Bool("isLastBinlogFile", isLastBinlogFile))
targetSeq, err := getBinlogNameSeq(binlogFileTarget.Name)
if err != nil {
return nil, fmt.Errorf("failed to parse seq from binlog file name %q", binlogFileTarget.Name)
diff --git a/server/task_executor_pitr_restore.go b/server/task_executor_pitr_restore.go
index a5e750606b..62e45b67e2 100644
--- a/server/task_executor_pitr_restore.go
+++ b/server/task_executor_pitr_restore.go
@@ -90,15 +90,15 @@ func (exec *PITRRestoreTaskExecutor) doPITRRestore(ctx context.Context, task *ap
return err
}
- log.Debug("Getting latest backup before or equal to targetTs...", zap.Time("targetTs", time.Unix(targetTs, 0)))
+ log.Debug("Getting latest backup before or equal to targetTs", zap.Int64("targetTs", targetTs))
backup, err := mysqlDriver.GetLatestBackupBeforeOrEqualTs(ctx, backupList, targetTs, mode)
if err != nil {
- dateTime := time.Unix(targetTs, 0).Format(time.RFC822)
+ targetTsHuman := time.Unix(targetTs, 0).Format(time.RFC822)
log.Error("Failed to get backup before or equal to time",
- zap.String("dateTime", dateTime),
- zap.Time("targetTs", time.Unix(targetTs, 0)),
+ zap.Int64("targetTs", targetTs),
+ zap.String("targetTsHuman", targetTsHuman),
zap.Error(err))
- return fmt.Errorf("failed to get latest backup before or equal to %s, error: %w", dateTime, err)
+ return fmt.Errorf("failed to get latest backup before or equal to %s, error: %w", targetTsHuman, err)
}
log.Debug("Got latest backup before or equal to targetTs", zap.String("backup", backup.Name))
backupFileName := getBackupAbsFilePath(dataDir, backup.DatabaseID, backup.Name)