yandex: reduce reconnect churn (participant pile-up) and close stale conns - #55
Open
D13tre33 wants to merge 1 commit into
Open
yandex: reduce reconnect churn (participant pile-up) and close stale conns#55D13tre33 wants to merge 1 commit into
D13tre33 wants to merge 1 commit into
Conversation
Two small reconnect-hygiene fixes: - Every WebSocket reconnect registers as a brand new participant in the doc's collab room server-side, regardless of client-side userID reuse (confirmed by logging the server's participant-list messages during a failure streak - saw 2-3 simultaneous "ghost" participants pile up across repeated reconnects). A tight failure loop churns through these fast. Raised reconnectBackoff()'s floor from 500ms to 1.5s and its cap from 15s to 30s to slow that down; this doesn't touch steady-state throughput since successful connects never hit backoff. - The main read loop's error branch never called conn.Close() on the WebSocket, leaving the local socket to clean up whenever the runtime got around to it instead of promptly.
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.
Summary
Follow-up to #54 (which fixes the yandex transport's handshake race).
With that race fixed, sessions establish reliably, but I noticed
something else while watching a live exit node for a while afterward:
a session that fully succeeds still eventually gets an explicit
server-side disconnect (
disconnectReasoncode 4007,"drop") afterroughly 60-90 seconds.
While digging into that (not fixed here - see below), I logged the
server's
auth/connectStatemessages, which list the doc room'scurrent participants. Every WebSocket reconnect - even ones that fail
fast - registers as a brand new "Anonymous" participant server-side
(Yandex assigns its own participant id per connection and ignores our
client-side
user.id). During a failure streak I saw 2-3 simultaneousghost participants pile up in the same room from nothing but our own
reconnect attempts.
This PR doesn't fix the underlying
4007/dropbehavior (that lookslike it's coming from Yandex's own collab-session participant limits,
not something client-side code controls), but it does reduce how fast
our own retries can pile up participants:
reconnectBackoff()'s floor goes from 500ms to 1.5s and its capfrom 15s to 30s. Successful connects never hit backoff at all, so
this only affects failure streaks.
conn.Close()insteadof leaving the socket for the runtime to clean up whenever.
Test plan
CGO_ENABLED=0 go buildsucceeds (via the repo's Dockerfile)new backoff floor/cap take effect on reconnect