Skip to content

Sender: configurable DB pool, honest concurrency, one probe for a down domain - #56

Merged
markmnl merged 1 commit into
mainfrom
sender-pool-and-unreachable-domains
Nov 26, 2026
Merged

markmnl merged 1 commit into
mainfrom
sender-pool-and-unreachable-domains

Conversation

@markmnl

@markmnl markmnl commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Summary

Part of #55.

A delivery holds one connection from the sender's database pool for its whole exchange. The pool was fixed at 32, so that was the real limit on outbound deliveries whatever FMSG_MAX_CONCURRENT_SEND said, and a backlog for an unreachable domain could hold every connection for a connect timeout at a time while deliveries to healthy domains waited.

  • FMSG_SENDER_DB_MAX_CONNS sets the sender pool size (default 32, minimum 2).
  • The delivery limit is what can actually run: the smaller of FMSG_MAX_CONCURRENT_SEND and the pool size minus one connection kept for the query that finds pending work. Deliveries no longer queue for a connection while holding a slot, and the start-up log line states the number.
  • A domain that can't be reached gets one delivery at a time. After a failed DNS lookup or connect, further deliveries to that domain wait for a later poll while one is in flight. The first connection that succeeds lifts the limit. Domains not known to be down are unaffected.

Defaults: with nothing configured, 31 deliveries run at once (it was 32, with the poll query competing for the same connections).

Not changed: deliveries still hold a connection across network I/O (the second option in #55), and the first burst to a domain that has just gone down can still take every slot until its first connect fails.

Testing

  • New cmd/fmsgd/sender_dispatch_test.go: the slot calculation, target de-duplication, and the one-at-a-time rule for an unreachable domain including recovery.
  • go vet ./... and go test -race ./... pass.

🤖 Generated with Claude Code

…n domain

A delivery holds one connection from the sender's database pool for its
whole exchange, so the pool, fixed at 32, was the real limit on outbound
deliveries whatever FMSG_MAX_CONCURRENT_SEND said, and a backlog for an
unreachable domain could hold every connection for a connect timeout at a
time while deliveries to healthy domains waited.

- FMSG_SENDER_DB_MAX_CONNS sets the pool size (default 32, minimum 2).
- The delivery semaphore is sized to what can actually run: the smaller of
  FMSG_MAX_CONCURRENT_SEND and the pool minus one connection kept for the
  query that finds pending work. Deliveries no longer queue for a
  connection while holding a slot, and the start-up log states the number.
- A domain the sender could not resolve or connect to gets one delivery at
  a time until a connection to it succeeds. The rest of its backlog waits
  for a later poll instead of occupying delivery slots.

Part of #55; deliveries still hold a connection across network I/O.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@markmnl
markmnl merged commit 4faa503 into main Nov 26, 2026
2 checks passed
@markmnl
markmnl deleted the sender-pool-and-unreachable-domains branch November 26, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant