Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: only print debug log when things happen (#2485)
Yilong Li5f873d5e82b4
diff --git a/plugin/db/mysql/restore.go b/plugin/db/mysql/restore.goindex 587e255ba2..1529b08f20 100644--- a/plugin/db/mysql/restore.go+++ b/plugin/db/mysql/restore.go@@ -25,7 +25,6 @@ import ("time""go.uber.org/zap"- "go.uber.org/zap/zapcore""github.com/pkg/errors"@@ -72,17 +71,6 @@ func newBinlogFile(name string, size int64) (BinlogFile, error) {return BinlogFile{Name: name, Size: size, Seq: seq}, nil}-// ZapBinlogFiles is a helper to format zap.Array.-type ZapBinlogFiles []BinlogFile--// MarshalLogArray implements the zapcore.ArrayMarshaler interface.-func (files ZapBinlogFiles) MarshalLogArray(arr zapcore.ArrayEncoder) error {- for _, file := range files {- arr.AppendString(fmt.Sprintf("%s[%d]", file.Name, file.Size))- }- return nil-}-type binlogCoordinate struct {Name stringSeq int64@@ -570,7 +558,6 @@ func (driver *Driver) downloadBinlogFilesOnServer(ctx context.Context, metaListfor _, meta := range metaList {metaMap[meta.seq] = true}- log.Debug("Downloading binlog files", zap.Array("fileList", ZapBinlogFiles(binlogFilesOnServerSorted)))for _, fileOnServer := range binlogFilesOnServerSorted {isLatest := fileOnServer.Name == latestBinlogFileOnServer.Nameif isLatest && !downloadLatestBinlogFile {@@ -579,6 +566,7 @@ func (driver *Driver) downloadBinlogFilesOnServer(ctx context.Context, metaList_, exist := metaMap[fileOnServer.Seq]if !exist || isLatest {binlogFilePath := filepath.Join(driver.binlogDir, fileOnServer.Name)+ log.Debug("Downloading binlog file from MySQL server.", zap.String("path", binlogFilePath), zap.Bool("isLatest", isLatest))if err := driver.downloadBinlogFile(ctx, fileOnServer, isLatest); err != nil {log.Error("Failed to download binlog file", zap.String("path", binlogFilePath), zap.Error(err))return errors.Wrapf(err, "failed to download binlog file %q", binlogFilePath)@@ -639,6 +627,9 @@ func (driver *Driver) syncBinlogMetaFileFromCloud(ctx context.Context, client *bif err != nil {return errors.Wrapf(err, "failed to get binlog metadata file list on cloud in directory %q", driver.binlogDir)}+ if len(metaListToDownload) == 0 {+ return nil+ }log.Debug(fmt.Sprintf("Downloading %d binlog metadata file from cloud storage", len(metaListToDownload)))for _, metaFileName := range metaListToDownload {diff --git a/server/backup_runner.go b/server/backup_runner.goindex 2c10a837da..d33a45f38a 100644--- a/server/backup_runner.go+++ b/server/backup_runner.go@@ -51,7 +51,6 @@ func (r *BackupRunner) Run(ctx context.Context, wg *sync.WaitGroup) {for {select {case <-ticker.C:- log.Debug("New auto backup round started...")func() {defer func() {if r := recover(); r != nil {@@ -83,7 +82,6 @@ func (r *BackupRunner) purgeExpiredBackupData(ctx context.Context) {return}- log.Debug("Deleting expired backups.")for _, bs := range backupSettingList {if bs.RetentionPeriodTs == api.BackupRetentionPeriodUnset {continue // next database@@ -97,6 +95,7 @@ func (r *BackupRunner) purgeExpiredBackupData(ctx context.Context) {backupTime := time.Unix(backup.UpdatedTs, 0)expireTime := backupTime.Add(time.Duration(bs.RetentionPeriodTs) * time.Second)if time.Now().After(expireTime) {+ log.Debug("Purging expired backup", zap.Int("databaseID", backup.DatabaseID), zap.String("backup", backup.Name), zap.String("storageBackend", string(backup.StorageBackend)))if err := r.purgeBackup(ctx, backup); err != nil {log.Error("Failed to purge backup", zap.String("backup", backup.Name), zap.Error(err))}@@ -104,7 +103,6 @@ func (r *BackupRunner) purgeExpiredBackupData(ctx context.Context) {}}- log.Debug("Deleting expired MySQL binlog files.")instanceList, err := r.server.store.FindInstance(ctx, &api.InstanceFind{})if err != nil {log.Error("Failed to find non-archived instances.", zap.Error(err))@@ -123,7 +121,6 @@ func (r *BackupRunner) purgeExpiredBackupData(ctx context.Context) {if maxRetentionPeriodTs == math.MaxInt {continue}- log.Debug("Deleting old binlog files for MySQL instance.", zap.String("instance", instance.Name))if err := r.purgeBinlogFiles(instance.ID, maxRetentionPeriodTs); err != nil {log.Error("Failed to purge binlog files for instance", zap.String("instance", instance.Name), zap.Int("retentionPeriodTs", maxRetentionPeriodTs), zap.Error(err))}@@ -167,6 +164,7 @@ func (r *BackupRunner) purgeBinlogFiles(instanceID, retentionPeriodTs int) errorexpireTime := fileInfo.ModTime().Add(time.Duration(retentionPeriodTs) * time.Second)if time.Now().After(expireTime) {binlogFilePath := path.Join(binlogDir, binlogFileInfo.Name())+ log.Debug("Deleting expired binlog file for MySQL instance.", zap.String("path", binlogFilePath))if err := os.Remove(binlogFilePath); err != nil {log.Warn("Failed to remove an expired binlog file.", zap.String("path", binlogFilePath), zap.Error(err))continue@@ -206,7 +204,6 @@ func (r *BackupRunner) downloadBinlogFiles(ctx context.Context) {return}- log.Debug(fmt.Sprintf("Downloading binlog files for %d MySQL instances.", len(instanceList)))r.downloadBinlogMu.Lock()defer r.downloadBinlogMu.Unlock()for _, instance := range instanceList {@@ -219,7 +216,6 @@ func (r *BackupRunner) downloadBinlogFiles(ctx context.Context) {}func (r *BackupRunner) downloadBinlogFilesForInstance(ctx context.Context, instance *api.Instance) {- log.Debug("Downloading binlog files for MySQL instance", zap.String("instance", instance.Name))defer func() {r.downloadBinlogMu.Lock()delete(r.downloadBinlogInstanceIDs, instance.ID)