fix: logging

This commit is contained in:
Richard Ramos 2024-08-08 14:07:57 -04:00
parent 167b65b68d
commit 131a94ec20
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760

View File

@ -174,7 +174,7 @@ func Execute(ctx context.Context, options Options) error {
go func() {
syncCheckTimer := time.NewTicker(30 * time.Minute)
syncCheckTimer := time.NewTimer(0)
defer syncCheckTimer.Stop()
for {
@ -186,7 +186,6 @@ func Execute(ctx context.Context, options Options) error {
tmpUUID := uuid.New()
runId := hex.EncodeToString(tmpUUID[:])
runIdLogger := logger.With(zap.String("syncRunId", runId))
runIdLogger.Info("rechecking missing messages status")
err := application.checkMissingMessageStatus(ctx, storenodeIDs, runId, runIdLogger)
if err != nil {
@ -201,6 +200,8 @@ func Execute(ctx context.Context, options Options) error {
}
runIdLogger.Info("missing messages recheck complete")
syncCheckTimer.Reset(30 * time.Minute)
}()
}
}
@ -358,9 +359,14 @@ func (app *Application) verifyHistory(ctx context.Context, runId string, storeno
func (app *Application) checkMissingMessageStatus(ctx context.Context, storenodes []peer.ID, runId string, logger *zap.Logger) error {
now := app.node.Timesource().Now()
from := now.Add(-2 * time.Hour)
to := now.Add(-time.Hour)
logger.Info("rechecking missing messages status", zap.Time("from", from), zap.Time("to", to), zap.Uint("clusterID", options.ClusterID))
// Get all messages whose status is missing or does not exist, and the column found_on_recheck is false
// if found, set found_on_recheck to true
missingMessages, err := app.db.GetMissingMessages(now.Add(-2*time.Hour), now.Add(-time.Hour), options.ClusterID)
missingMessages, err := app.db.GetMissingMessages(from, to, options.ClusterID)
if err != nil {
return err
}