fix: update lastSuccessTimestamp after each request too

Updating only in run() can be delayed arbitrarily long under load.
main^2
Max Ignatenko 2024-11-14 12:34:13 +00:00
parent 2c6a7201ef
commit b26866fe0c
1 changed files with 3 additions and 2 deletions

View File

@ -201,11 +201,12 @@ func (m *Mirror) runOnce(ctx context.Context) error {
return fmt.Errorf("inserting log entry into database: %w", err) return fmt.Errorf("inserting log entry into database: %w", err)
} }
m.mu.Lock()
m.lastSuccessTimestamp = time.Now()
if !lastTimestamp.IsZero() { if !lastTimestamp.IsZero() {
m.mu.Lock()
m.lastRecordTimestamp = lastTimestamp m.lastRecordTimestamp = lastTimestamp
m.mu.Unlock()
} }
m.mu.Unlock()
log.Info().Msgf("Got %d log entries. New cursor: %q", len(newEntries), cursor) log.Info().Msgf("Got %d log entries. New cursor: %q", len(newEntries), cursor)
} }