fix(sdk): reject zero durations that spin client loops - #3891
fix(sdk): reject zero durations that spin client loops#3891ethanlin01x wants to merge 5 commits into
Conversation
A zero heartbeat interval pings without pause, and a zero reconnection interval with unlimited retries spins on connect. Found during review of apache#3776.
A zero init retry interval panics the timer it builds; a zero polling retry interval and a zero auto-commit interval both spin.
Only when a retry count is set, since send_internal never reads the interval without one.
The heartbeat loop is transport-agnostic, so the TCP fence left both open.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3891 +/- ##
============================================
- Coverage 82.96% 81.46% -1.51%
Complexity 1339 1339
============================================
Files 1218 1218
Lines 165595 159850 -5745
Branches 133910 128290 -5620
============================================
- Hits 137394 130229 -7165
- Misses 24540 25593 +1053
- Partials 3661 4028 +367
🚀 New features to boost your workflow:
|
|
/request-review @hubcio |
|
/ready |
|
The problem is real for consumers:
producers:
and connection lifecycle:
Clarification:
Solution:
|
|
Thanks for the review. I agree that using So I would prefer to keep the current approach. What do you think? |
|
@ethanlin01x fair points.
|
|
@haubur breaking changes are totally fine at this stage, as we're very close to the next release, with lots of breaking changes anyway :) |
|
Thanks @spetz! So @ethanlin01x lets have a NonZeroIggyDuration for retries and heartbeats, while keeping the busy loop for AutoCommit on an interval = 0. Would you want to rewrite? Otherwise, I can also take this. |
Which issue does this PR address?
Relates to #3776 (Found while reviewing)
Rationale
Zero-valued durations reach loops that spin or panic. The CLI hits this today:
IggyDuration::from_strmaps0,none,disabledandunlimitedto the same zero, so--tcp-heartbeat-interval noneproduces a ping loop with no delay between round trips.#3776 guarded this inside the Python binding, but the hazard is not Python-specific. The fence belongs in the Rust SDK, where every binding funnels through.
What changed?
Validation added to five functions that already return
Result:TcpClient::create,QuicClient::create,WebSocketClient::create— zeroheartbeat_interval, or zeroreconnection.intervalwith unlimited retries. The heartbeat task is transport-agnostic, so all three shared the bug.IggyConsumer::init— zeroinit_retry_interval(panicstime::interval),polling_retry_interval(spins a core), or auto-commit interval (background task spins from spawn).ProducerCore::init— zero send retries interval, and only when a retry count is set.Zero stays legal where it means something: bounded fast-retry, reconnection disabled, auto-commit modes carrying no interval, and no retry budget.
Behavior change:
--tcp-heartbeat-interval noneand its--quic-/--websocket-equivalents now fail withInvalidConfigurationinstead of silently spinning.Local Execution
AI Usage