Repository navigation
agent: restart the retry loops when the network changes - #1929
Closed
Narasimha-sc wants to merge 1 commit into
Closed
Narasimha-sc wants to merge 1 commit into
Narasimha-sc wants to merge 1 commit into
Conversation
This was referenced Oct 5, 2026
Closed
Closed
Narasimha-sc
force-pushed
the
nd/net-retry-epoch
branch
from
October 5, 2026 10:46
a48338c to
e566c16
Compare
Narasimha-sc
force-pushed
the
nd/net-session-races
branch
from
October 5, 2026 10:46
6f39a94 to
c32661a
Compare
Narasimha-sc
force-pushed
the
nd/net-retry-epoch
branch
from
October 5, 2026 10:47
e566c16 to
8bcaa23
Compare
Narasimha-sc
force-pushed
the
nd/net-session-races
branch
from
October 5, 2026 16:13
c32661a to
231d6f9
Compare
Narasimha-sc
force-pushed
the
nd/net-retry-epoch
branch
from
October 5, 2026 16:13
8bcaa23 to
1bf277d
Compare
Closing the clients when the network changes makes the workers fail their current attempt, but a worker already waiting out its retry interval resumes only when it expires - up to the maximum interval, so delivery and subscriptions can take minutes after the network is usable again. The network epoch is incremented when the clients are closed, and the agent retry loops restart from the loop's initial interval when it changes - for delivery and XFTP workers resumed with persisted retry state that is the persisted interval (withRetryEpoch). Message delivery restarts the fast interval only, the slow interval for QUOTA errors is unchanged; the subscription worker keeps its foreground and online resets; retry attempt counters are not reset. A loop that was waiting for the network sees the epoch change after its first attempt, so if that attempt fails it retries once more without delay. withRetryWait2 now takes the value to sample before the action and a wait that receives the retry interval mode and returns whether the interval restarts, so one loop serves the plain, the lock and the epoch variants - the slow interval retries in STM and falls through to the plain wait, so it is unchanged. withRetryEpoch2 is withRetryLock2 without the lock, for the command worker, which retries with two intervals.
Narasimha-sc
force-pushed
the
nd/net-retry-epoch
branch
from
October 5, 2026 21:20
1bf277d to
925545c
Compare
Narasimha-sc
force-pushed
the
nd/net-session-races
branch
from
October 5, 2026 21:20
231d6f9 to
2c4ea1f
Compare
This was referenced Oct 20, 2026
Closed
Closed
This was referenced Oct 25, 2026
Draft
android, ios: report a network change when the network identity changes
Narasimha-sc/simplex-chat#40
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing the clients when the network changes makes the workers fail their current attempt, but a worker already waiting out its retry interval resumes only when it expires - up to the maximum interval, so delivery and subscriptions can take minutes after the network is usable again. This matters most when the IP changes without an offline event (a roam to another network, or a lease renewed while still associated): the workers are not parked on
waitForUserNetwork, they are in backoff, so closing the clients does not wake them.The network epoch is incremented when the clients are closed, and the agent retry loops restart from the loop's initial interval when it changes - for delivery and XFTP workers resumed with persisted retry state that is the persisted interval (
withRetryEpoch).With this, a reported IP change recovers in 3-4 s in the harness, against 808 s before the stack.
135 of the added lines are
RetryIntervalTestscovering the epoch, including mixed slow/fast intervals and an epoch change during the action.Rebased onto master
masterhad refactoredwithRetryLock2into a generalised internalwithRetryWait2, and moved the command worker from a single retry interval to two (loop RISlow/loop RIFast). Rather than duplicate master's loop,withRetryWait2is generalised once more: it takes the value to sample before the action - sampling before matters, so that an epoch change during the action also restarts the interval - and awaitthat receives theRetryIntervalModeand returns whether the interval restarts. One loop then serves the plain, lock and epoch variants.RISlowretries in STM and falls through to the plain wait, so the slow quota interval is byte-for-byte unchanged in behaviour.withRetryEpoch2is added for the command worker:withRetryLock2without the lock. It is covered by master's own parameterised 2-mode tests, which now run against all three variants.Retry intervalis 15 examples, 0 failures (was 11 before the rebase, as master's parameterisation adds cases);user network infois 5/5.Stack
Reducing reconnection delay after a network change. Each PR is based on the previous one and can be merged on its own once the ones below it are in.
mastermaster