Repository navigation
fix(topic-memory): stop redispatching exhausted work windows - #1842
Conversation
| if state.binding.work_block is not None: | ||
| try: | ||
| async with asyncio.timeout_at(admission_deadline), self._database.transaction() as connection: | ||
| await self._leases.require_fence(connection, fence) |
There was a problem hiding this comment.
[P1] A probe timeout on a blocked key erases the cached block and collapses its recheck spacing
_defer is called here without block=, and its last line unconditionally overwrites the entry:
state.retries[scope] = _RetryState(failures, deadline, block, request_generation)block defaults to None, so when the metadata probe raises — including the TimeoutError that asyncio.timeout_at(admission_deadline) raises whenever the probe overruns the shared 2.0s batch budget — a key that was already in terminal waiting loses its cached ArtifactProcessingBlock.
I reproduced this against 28685ce7 with the real ArtifactProcessingSupervisor and a stub probe that returns the same unchanged ArtifactProcessingBlock both times, only differing in whether it sleeps past _DISCOVERY_TIMEOUT_SECONDS:
=== step 1: clean recheck of a terminal frontier ===
block cached : True
failures : 0
recheck spacing : 300.0s (blocked_check_seconds=300)
=== step 2: identical block, but the probe overruns the 2.0s budget ===
block still cached : False
failures : 1
recheck spacing : 30.0s (retry_base=30)
Impact, against the contract this PR states in docs/en/rfcs/1515_artifact_processing_supervisor.md ("Unchanged cached checks neither spawn Workers nor add failures or repeated error logs") and in docs/zh/rfcs/1417_topic_memory.md:
- The 300s recheck spacing collapses to the 30s transient-failure backoff, so an unchanged terminal frontier is re-probed and re-reported roughly 10x more often while the database is under load.
failuresincrements even though nothing about the scope changed, which feeds the ordinary exponential backoff and theretry_wait/failedcounters that this PR otherwise keeps at zero for terminal keys.- The dedup in
_wait_for_block(if previous is None or previous.block != block) can no longer suppress the repeat, becauseprevious.blockis nowNonerather than the cached block.
The failure branch already knows whether it was deferring a previously blocked key — retry.block is not None is in scope. Please carry that block (and its request_generation) into _defer on the probe-error path, or re-derive it before deferring, so a probe timeout is recorded as a recheck attempt rather than converting terminal waiting into ordinary failure backoff.
Probe: oceanbase-powercontext-pr-1842/probes/block_erasure_probe.py. Related, same root cause: the batch's single admission_deadline means whichever scope is in flight when the budget expires is charged a full retry failure and an artifact_processing.failed ERROR log with error_code='TimeoutError', although nothing is wrong with that scope. probes/admission_timeout_attribution_probe.py shows the attribution.
There was a problem hiding this comment.
Thanks for catching this and providing the reproductions. I confirmed both issues and fixed them in a18d184: failed rechecks now preserve the terminal block, waiting interval and diagnostic deduplication, and each probe gets its full I/O timeout independently of earlier Scopes. Regression tests are included, and all 25 CI checks now pass, including Python 3.11–3.14.
a18d184 to
a547cca
Compare
a547cca to
0b4eec6
Compare
Bring in the database-migration prototype (oceanbase#1771/oceanbase#1772), loopback proxy bypass (oceanbase#1888), topic-memory window fixes (oceanbase#1842/oceanbase#1898) and related work. Resolve three conflicts: - database.py: keep the split transaction/_transaction so cancellation cleanup still owns the connection; adopt the upstream nested-snapshot comment. - test_sqlite_profile.py: keep this branch's SyncConnection/event imports and its invalidation + commit-mark regression tests. - test_topic_memory_generic_api.py: adopt upstream's reworked cancellation e2e (completion-flush rendezvous with busy_timeout_ms=100), which retains the cancellation, normal/storage-failure, settlement and recovery-usage assertions through the public flush boundary. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Which issue or RFC does this PR close?
Closes #1841. Aligns the Topic Memory and Artifact Processing Supervisor contracts in RFCs #1417 and #1515.
Rationale for this change
An exhausted Topic Memory frontier was repeatedly dispatched to a full child Worker, rejected before inference and counted as another processing failure. Legacy rows with attempts=3 and an empty failure_code exhibit the same problem.
The Supervisor needs to retain an unchanged terminal frontier without spawning more Workers or discarding accepted work. A failed metadata recheck must preserve that state, and checking other Scopes must not shorten a healthy Scope's probe allowance.
What changes are included in this PR?
Are there any user-facing changes?
An exhausted window emits an actionable artifact_processing.blocked warning and waits for remediation. Unchanged cached rechecks do not spawn Workers or manufacture execution failures. Failed rechecks preserve the last observed terminal state, and deliberate repair can restore eligibility without restart.
Flush, restart and model changes do not reset durable allowance. Existing attempt/request/token ceilings and data-retention rules remain in force. No public API, database schema, migration or automatic reset is added.
How was this change tested?
Validated head: 0b4eec6, based on master 77cf867.
The 1005-Scope automatic cache-overflow fixture exceeded its existing 20-second watchdog in the Windows 3.12 combined run and a two-case rerun. An isolated run passed with the original watchdog and assertions. Diagnostic sampling also showed continuous scan progress with no failed processing or degraded state. This fixture has timing sensitivity on this host; production deadlines and test assertions are unchanged.
The terminal-frontier end-to-end regression uses file-backed SQLite, production Server/HTTP bindings, genuine spawned Workers and a local OpenAI-compatible model stub. This establishes local behavior; it does not establish terminal-frontier-specific live OceanBase or remote-model execution.
AI usage statement
OpenAI Codex assisted with implementation, review and validation. Open Code Review was used in delegation mode for deterministic file selection and rule resolution.