You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sender pool size caps outbound concurrency; deliveries hold a DB connection across network I/O #55
deliverUnit opens a transaction on the sender's database pool, locks its recipient rows, and holds that connection through the DNS lookup, TLS dial, upload and response reads. The pool has 32 connections (senderDBMaxOpenConns in cmd/fmsgd/store.go), so:
At most 32 deliveries run at once, whatever FMSG_MAX_CONCURRENT_SEND is set to (default 1024). The other goroutines wait in db.Begin() while holding their semaphore slot.
A backlog for an unreachable domain delays everything else. Each attempt holds a connection for the 10s dial per IP, so 1,000 pending messages for a dead peer occupy the pool for about five minutes while deliveries to healthy domains wait.
findPendingTargets uses the same pool, so the poll waits too.
fmsgd can open up to 80 connections (48 inbound and indicators, 32 sender) against a PostgreSQL default max_connections of 100 that is usually shared with fmsg-webapi.
Options
Make the sender pool size configurable (for example FMSG_SENDER_DB_MAX_CONNS) and bound it by FMSG_MAX_CONCURRENT_SEND, so the documented knob and the real limit agree.
Stop holding a transaction across network I/O: claim the rows and commit, deliver, then record the outcomes in a second short transaction. This removes the coupling between network time and database connections, but the FOR UPDATE SKIP LOCKED row locks currently provide the mutual exclusion between senders, so the claim needs its own marker (for example a lease column or timestamp).
Independently of either: avoid one dead domain taking every slot, for example a per-domain cap on in-flight deliveries.
Option 2 is the complete fix. Option 1 is a small step that can land first.
Activity
Sender: configurable DB pool, honest concurrency, one probe for a dow…