Repository navigation
fix: retry pusher close admission refusals without write-failure backoff - #24189
Conversation
Retry pre-write capacity refusals on short jitter without consuming the write-failure ladder, and count the closed admission/outstanding reasons. Keep durable token proof and all concurrency and deadline bounds intact.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fec9602fe4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def _close_admission_refused(self, conversation_id: str) -> bool: | ||
| # The drain loop already yields between scans. A positive, jittered | ||
| # retry time also bounds admission checks without adding tasks/timers. | ||
| self.close_retry_at[conversation_id] = time.monotonic() + random.uniform(0.5, 2.0) | ||
| return False |
There was a problem hiding this comment.
Include admission-only retries in closed-drain ownership
When a durable session has only a seal left to perform (an empty reconnect, or a session whose token clears already succeeded), admission refusals now populate only close_retry_at, leaving upload_sessions, pending_clears, and close_failures empty. If contention persists through the 30-second socket drain timeout—for example, because the outstanding-call cap remains occupied—drain_socket_tasks() in backend/routers/pusher.py:1795–1800 sees no record debt and does not retain the worker; final cleanup then cancels its pending seal. Previously these refusals populated close_failures, preserving worker ownership. Include close_retry_at or pending close requests in the handoff predicate so this change does not abandon admission-only seal retries.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b4956c1 (ownership delta 0191b2d / 3cc7a7c). The socket-to-process retention condition now includes close_retry_at. Two real-router regressions cover empty reconnects and a successful token clear followed by a real seal admission refusal: the same worker survives the drain budget, seals after capacity returns, and retire_close removes the retry state. The focused shard plus existing label guard passes 109 tests; targeted hermetic listen/pusher E2E passes 20. No concurrency or deadline bounds changed.
Include pending admission retry timestamps in the socket-to-process debt predicate after token clears succeed. Exercise empty reconnects and cleared tokens through the real router, retained worker and eventual durable seal.
Keep both reason children statically closed for the existing AST guard, without extending label debt or changing admission behavior.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3cc7a7cfa3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| RECORD_CLOSE_REFUSALS = Counter( | ||
| 'omi_pusher_record_close_refusals_total', | ||
| 'Close metadata calls refused before any write is submitted', | ||
| ['reason'], | ||
| ) |
There was a problem hiding this comment.
Update the required pusher pipeline contract
backend/AGENTS.md requires listen/pusher WebSocket changes to update backend/docs/listen_pusher_pipeline.mdx in the same PR, but this commit leaves that contract unchanged. Its “Pusher receive work and committed projection capacity” section still specifies seven metric families and the old series budget, omitting the new refusal counter and the distinction between admission retries and write-failure backoff. Update that section with the new metric, retry behavior, and seal-only drain ownership so release verification covers contention that no longer appears in finish/seal failure metrics.
AGENTS.md reference: backend/AGENTS.md:L164-L164
Useful? React with 👍 / 👎.
Problem and change
At four active close calls, pusher refused admission before submitting a write, then counted that refusal as a finish/seal failure and advanced the exponential retry ladder. Retained drain workers could consequently wait 30–60 seconds for capacity that had already returned.
Count pre-write refusals in
omi_pusher_record_close_refusals_total{reason="admission"|"outstanding"}and retry them after 0.5–2 seconds of jitter without advancing the failure ladder or finish/seal failure metrics. Preserve the existing outstanding-cap metric. Actual write exceptions retain the existing exponential backoff. The four active calls, twelve outstanding calls, thirty-second deadline, drain cap and receive queue wait remain unchanged. Tokens clear only after successful durable writes.The closed-socket ownership predicate includes
close_retry_at, so a seal-only admission retry retains its worker after the token clear succeeds or on an empty reconnect. Successful retirement clears that scheduling state.Validation
TZ=UTC BACKEND_PYTEST_WORKERS=1 BACKEND_UNIT_TEST_FILE_LIST=/Volumes/Ephemeral/scratch/closeadmit/tests.txt /Users/dazheng/workspace/omi/bin/omi-heavy run -- nice -n 19 bash backend/test.sh: 109 passed across record barrier executor, pusher queue wait, record seal and the existing reason-label guard tests. Real barrier and strict Firestore cover admission versus real write failures, retry suppression, retained tokens, and a fifth close completing after one of four held slots frees. Real-router cases also cover seal-only refusal past socket drain, same-worker retention and eventual seal for empty reconnects and successfully cleared tokens.TZ=UTC /Users/dazheng/workspace/omi/bin/omi-heavy run -- nice -n 19 bash backend/testing/e2e/run.sh -q --tb=short -k 'listen_pusher_wire_contract or listen_stt': 20 passed, 165 deselected. Real backend routes and wire contract against hermetic dependencies; not live production acceptance.TZ=UTC BACKEND_PYTEST_WORKERS=1 /Users/dazheng/workspace/omi/bin/omi-heavy run -- nice -n 19 scripts/pr-preflight --lane local --pr-body-file /Volumes/Ephemeral/scratch/closeadmit/pr-body.md: all 34 selected guards passed.Release acceptance
Lead owns merge and pusher deployment, alongside #24188. No production access or writes in this lane. After the new release serves, compare aggregate five-minute rates of
omi_pusher_record_close_refusals_total{reason="admission"},omi_pusher_record_barrier_failures_total{stage=~"finish|seal"}, andpusher_receive_work_stalled_handlers{stage="drain"}. A positive admission rate directly establishes contention; declining real failure/drain stock tests its operational impact. A quiet window cannot prove the prior wave's cause.Failure-Class: none
No existing failure-class definition matches pre-dispatch semaphore contention being charged as a storage write failure; this scoped change adds the typed boundary and behavioral guard without expanding the registry.