Skip to content

Fix: record alert key before send to prevent SMTP retry storm#85

Merged
GageLawton merged 2 commits into
mainfrom
claude/fix-alert-retry-74
May 25, 2026
Merged

Fix: record alert key before send to prevent SMTP retry storm#85
GageLawton merged 2 commits into
mainfrom
claude/fix-alert-retry-74

Conversation

@GageLawton
Copy link
Copy Markdown
Owner

Problem

notifyWeatherAlerts() only inserted an alert key into sentAlertKeys_ when sendEmail() returned true. During an SMTP outage the key was never stored, so the same failed connection was retried on every tick — one 30-second CURLOPT_TIMEOUT block per active alert per tick — silently hammering the mail server with no backoff.

File: src/alerter.cpp (was line 168)

Fix

Record the key in sentAlertKeys_ before the send attempt, unconditionally:

// Before
if (sendEmail(subj.str(), body.str())) {
    sentAlertKeys_.insert(key);
}

// After
sentAlertKeys_.insert(key);   // best-effort: record first, send once
sendEmail(subj.str(), body.str());

If SMTP is unavailable the alert email is dropped for this activation window. Best-effort loss of a single email is acceptable; repeated connection attempts against an unreachable server during an outage are not.

Test plan

  • Build passes (make -f test/Makefile.mac)
  • During normal operation, alert emails still arrive on first detection
  • With SMTP credentials broken, the same alert is attempted exactly once (not once per tick)

Closes #74

https://claude.ai/code/session_01WFdWug8ZDiJYr1ozfxwkn7

claude added 2 commits May 25, 2026 13:02
notifyWeatherAlerts() only inserted the alert key into sentAlertKeys_
when sendEmail() returned true. During an SMTP outage every tick re-
attempted the same failed connection (one 30s block per active alert
per tick), silently hammering the mail server with no backoff.

Record the key unconditionally before the send attempt. If SMTP is
down the alert is dropped for this activation window — best-effort
loss of one email is acceptable; repeated connection attempts during
an outage are not.

Fixes #74

https://claude.ai/code/session_01WFdWug8ZDiJYr1ozfxwkn7
The PR's change (record alert key before send to prevent retry storm) was
in notifyWeatherAlerts(), which main has since removed — weather-alert
emailing was replaced with journal logging in main. The conflicting hunk
was git confusing the old notifyWeatherAlerts body with drainEmailQueue();
resolution keeps main's drainEmailQueue() implementation unchanged.

https://claude.ai/code/session_01Lq2gNbRv9voqav7jsmQMnD
@GageLawton GageLawton merged commit 56484e3 into main May 25, 2026
2 checks passed
@GageLawton GageLawton deleted the claude/fix-alert-retry-74 branch May 25, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants