harness: cap concurrent re-attach streams, so attach readers cannot exhaust Redis connections (follow-up to #471)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- docker-compose, kubernetes, redis, typescript
- Domain
- backend, infrastructure
Research direction
Start in harness/src/turn-registry.ts, where attach() gives each GET /v1/turn request its own client.duplicate() connection, and follow how that connection is released on stream end, disconnect, and close(). Count open attach readers per process and per session, and return the documented status past the cap. Done means the (N+1)th concurrent attach gets that status and recovers when one ends, reader connections return to zero in a test, and the compose README, vm env example, and k8s base document the new settings. The 429 vs 409 choice and the default cap size are still open.
Written by the indexing model from the issue text.
Description
Follow-up from #471 (detachable turns). The final branch review deferred this by ruling.
Goal
One client, or a few, cannot exhaust the harness's Redis connections by opening re-attach streams.
Current state
TurnRegistry.attach()(harness/src/turn-registry.ts) gives everyGET /v1/turn?sessionId=its own duplicated Redis connection (client.duplicate()). This is necessary becauseXREAD BLOCKwould otherwise stall every other command on the shared client.- The connection is released when the stream ends, the client disconnects, or
close()runs. Nothing caps how many are open at once. There is no limit per process, per session, or per subject. - An authenticated client holding a valid session token can open attach streams in a loop. Each one holds a Redis connection until it ends, so the client can push Redis toward
maxclientsand starve everything else that shares it: sessions, leases, the control plane. - mocactl itself opens one attach per resume, and re-attaches at most 5 times after a dropped stream. Normal use is far below any sensible cap.
Scope
- Cap concurrent attach readers per process, for example
SH_TURN_ATTACH_MAXwith a default sized against the worker's Redis budget. Past the cap, answer503 {"error":"attach_unavailable"}withRetry-After. mocactl already retries on 503s that carryRetry-After. - Cap concurrent attaches per session at a small number (2–4), so one session cannot use the whole process budget. A further attach for that session gets
429or409; pick one and document it. - Optional: serve several attaches of the same turn from one reader in the process (fan-out). That would make the per-session cap mostly moot.
- Expose the current attach-reader count in the worker's advisory
statsmessage, so/metricscan show it.
Acceptance
- With the cap at N, the (N+1)th concurrent attach in a process gets the documented status, and it recovers once one ends.
- The per-session cap holds across attaches to the same session.
- A test shows reader connections return to zero after streams end, abort, or
close(). deploy/composeREADME, vm env example, and k8s base document the new settings.
- Dominant language
- TypeScript
- Stars
- 4
- Forks
- 9
- Avg merge
- 9h 2m
- Merged PRs (30d)
- 138
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rossoctl/moca
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rossoctl/moca#421 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
MoonshotAI/kimi-code#4398 ·
Maintainers usually reply within 1 day
-
Xiaomi Mimo语音识别服务异常Openpending triage
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
package-lock.json : les binaires natifs macOS et Linux de unrs-resolver ont disparu depuis #1823Openbug dependencies
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
AxaFrance/design-system#2064 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100