Skip to content

Recover interrupted outbound mail deliveries after a worker restart #13

Open

Description

@LunaStev

Problem

The worker persists delivering before SMTP submission, while PendingDeliveries selects only queued and deferred. There is no lease expiry or recovery path for a crash between these writes. Recovery and ordinary mail can remain stuck indefinitely.

Evidence / regression scenario

An isolated repository probe inserted a delivering record whose LastAttemptAt was 24 hours old; PendingDeliveries returned zero eligible records. This demonstrates missing eligibility, not an observed production outage.

Code references

Audit baseline: 50eb207.

Completion criteria

  • Define an explicit in-flight lease/expiry and recover interrupted work on startup or during polling without racing an active sender.
  • Distinguish an unsent retry from an ambiguous post-SMTP-acceptance crash; document the at-least-once/duplicate-delivery limitation rather than promising exactly-once SMTP.
  • Cover restart before submission, failure while persisting completion, and normal success with a fake sender and temporary database.
  • Keep message IDs stable across retries and preserve the existing bounded retry policy.

Scope and dependencies

Difficulty: high.

Owns worker recovery only. Administrative retry/cancel controls are separate tasks. Never send real mail in tests.

Backlog index: #12. Keep the change limited to this issue and include focused verification in the pull request.

Activity

  1. added
    bug
    help wanted
    mail
    priority high
    needs testing
    on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp wantedmailneeds testingpriority high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions