Fix: record alert key before send to prevent SMTP retry storm#85
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
notifyWeatherAlerts()only inserted an alert key intosentAlertKeys_whensendEmail()returnedtrue. During an SMTP outage the key was never stored, so the same failed connection was retried on every tick — one 30-secondCURLOPT_TIMEOUTblock 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: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
make -f test/Makefile.mac)Closes #74
https://claude.ai/code/session_01WFdWug8ZDiJYr1ozfxwkn7