matrix sync: skip a member's remaining rooms after a transport error
ci/woodpecker/push/woodpecker Pipeline was canceled
ci/woodpecker/push/woodpecker Pipeline was canceled
An unreachable remote homeserver hangs every invite POST to that member until the client timeout (8 rooms x 30s), which outlived the 5-minute service-sync tick and starved every member queued behind it. Raise a member-scoped _TransportError instead of returning False, skip that member's remaining rooms for this pass, and report transport_skipped in the result. Invites stay idempotent, so the next pass retries. Test: a timed-out member is attempted once, not once per room.
This commit is contained in:
1 parent
d190aa7762
commit
419b1f4322
2 files changed
+39
-9
No files matched your search
@@ -74,6 +74,7 @@ UNREADABLE = set() # rooms whose joined_members 500s
|
||||
invites_sent = [] # (room, mxid)
|
||||
INVITE_429_FOR = set() # mxids whose invite comes back 429
|
||||
INVITE_TIMEOUT_FOR = set() # mxids whose invite POST raises httpx.ReadTimeout
|
||||
TIMEOUT_ATTEMPTS = [] # (room, mxid) for every POST that timed out
|
||||
POSTS = [] # Loomio POST payloads
|
||||
|
||||
ROSTER = {} # Loomio roster: email -> membership id
|
||||
@@ -129,6 +130,7 @@ class FakeClient:
|
||||
if "/invite" in url:
|
||||
mxid = (json or {}).get("user_id")
|
||||
if mxid in INVITE_TIMEOUT_FOR:
|
||||
TIMEOUT_ATTEMPTS.append((url, mxid))
|
||||
raise httpx.ReadTimeout("timed out")
|
||||
if mxid in INVITE_429_FOR:
|
||||
return FakeResp(429, {"retry_after_ms": 300000},
|
||||
@@ -165,6 +167,7 @@ def reset():
|
||||
global invites_sent
|
||||
invites_sent = []
|
||||
POSTS.clear()
|
||||
TIMEOUT_ATTEMPTS.clear()
|
||||
|
||||
|
||||
async def main():
|
||||
@@ -209,8 +212,8 @@ async def main():
|
||||
not any(mx == "@amember:inference.coop" for _, mx in invites_sent))
|
||||
check("per-room: two members can be pending on different rooms",
|
||||
not any(mx == "@cmember:inference.coop" for _, mx in invites_sent))
|
||||
check("return shape: the result carries invited + rate_limited",
|
||||
set(r) == {"invited", "rate_limited"} and r["rate_limited"] is False)
|
||||
check("return shape: the result carries invited + rate_limited + transport_skipped",
|
||||
set(r) == {"invited", "rate_limited", "transport_skipped"} and r["rate_limited"] is False)
|
||||
|
||||
# --- 2. IDEMPOTENCE: a second pass sends nothing ----------------------
|
||||
reset()
|
||||
@@ -325,6 +328,10 @@ async def main():
|
||||
{room for room, _ in invites_sent} == set(ROOMS)
|
||||
and all(mx == "@umember:inference.coop" for _, mx in invites_sent))
|
||||
check("timeout: the timed-out member is not counted as invited", r["invited"] == 1)
|
||||
check("timeout: a timed-out member is attempted ONCE, not once per room",
|
||||
len(TIMEOUT_ATTEMPTS) == 1)
|
||||
check("timeout: the pass reports the member whose rooms it skipped",
|
||||
r.get("transport_skipped") == 1)
|
||||
|
||||
# The next pass retries the timed-out member (invites are idempotent).
|
||||
INVITE_TIMEOUT_FOR = set()
|
||||
|
||||
Reference in new issue
Block a user