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
Commit 8396b98
Browse filesBrowse the repository at this point in the historyBrowse files
Bound subscriber statements so loops reconnect after a silent primary loss (#262)
* Bound subscriber statements so loops reconnect after a silent primary loss
A fetch or terminal write on a connection whose primary vanished without
closing it (power loss, network partition) hung until the kernel's TCP
timeout, so the subscriber stopped consuming after a failover. Each fetch,
delete, batch delete and retry update is now capped at the new
query_timeout_seconds subscriber option (default: lease_ttl_seconds); on
timeout the connection is invalidated and the loop reconnects.
Adds failover drills (just test-dr): a primary/streaming-replica compose
cluster where the primary is either killed or cut off from the network and
the replica is promoted. Not part of CI.
* Skip failover drills unless DR_CLUSTER_DSN is set
The floors job runs pytest . and sets POSTGRES_DSN, so the drills were
collected and tried to connect to a cluster that does not exist.
Copy file name to clipboardExpand all lines: docs/usage/subscriber.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,7 @@ Per-subscriber knobs, passed to `@broker.subscriber("…", …)`:
90
90
|`min_fetch_interval`|`1.0` s | Base for the adaptive idle backoff (jittered ±50%, so an actual wait can land below it); no sleep at all while fetches keep returning rows |
91
91
|`max_fetch_interval`|`10.0` s | Ceiling for the adaptive idle backoff (with jitter) |
92
92
|`lease_ttl_seconds`|`60.0` s | How long a claim is valid before another fetch may reclaim it. Must exceed your handler's P99 with margin. |
93
+
|`query_timeout_seconds`|`None` (uses `lease_ttl_seconds`) | Client-side cap on each fetch and terminal write. A statement still running when it expires is abandoned, its connection is closed, and the loop reconnects. Set it below a long lease so a lost primary is noticed sooner. Must be `> 0` and at most `lease_ttl_seconds`. See [Database failover](#database-failover). |
93
94
|`max_deliveries`|`None` (unbounded) | Total claims (including lease-expiry re-claims) after which the row is dropped without invoking the handler. Defends against handlers that consistently wedge. Must be at least `1`; use `None`, not `0`, for no cap. |
94
95
|`terminal_flush_batch_size`|`1` (off) | Coalesce completed terminal `DELETE`s into one `DELETE … RETURNING` per N rows. `1` is one round-trip per message (unchanged). Higher trades a wider crash-redelivery window for far fewer round-trips. See [Batching terminal deletes](#batching-terminal-deletes). |
95
96
|`ack_policy`|`AckPolicy.NACK_ON_ERROR`| See [Ack policy](#ack-policy)|
@@ -360,6 +361,39 @@ startup with `FATAL: too many connections`.
0 commit comments