Repository navigation
fix(telegram): persist update offset only after durable spool write in isolated polling - #113368
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 3:46 AM ET / 07:46 UTC. ClawSweeper reviewWhat this changesThe PR changes isolated Telegram polling so an update is durably written to the ingress spool before its polling offset is persisted and the worker is acknowledged, with regressions for ordering and failure paths. Merge readinessKeep this PR open for normal landing review: the current branch appears to correctly close the isolated polling spool-before-offset crash window, preserves the broader report as open work, and has no remaining code-level finding. It is behind current Priority: P1 Review scores
Verification
How this fits togetherTelegram's isolated polling worker receives updates from Telegram and asks the parent session to durably hand them to the ingress spool. The parent then records the polling offset and acknowledges the worker, determining whether Telegram may redeliver an update after a failure. flowchart LR
A[Telegram getUpdates] --> B[Isolated polling worker]
B --> C[Parent spool handoff]
C --> D{Durable spool succeeds?}
D -->|yes| E[Persist polling offset]
E --> F[Worker acknowledgment]
D -->|no| G[Failure acknowledgment and redelivery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +30, Tests +115. Total +145 across 2 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase or refresh the merge result against current Do we have a high-confidence way to reproduce the issue? No independent live reproduction was performed in this read-only review; however, the prior failure window is high-confidence source-reproducible and is directly covered by the branch's ordered spool, persistence, and acknowledgement regressions. Is this the best way to solve the issue? Yes. Using the existing serialized parent-worker handoff to make durable spool success precede offset persistence is the narrowest maintainable repair, and removing the isolated-mode post-dispatch callback prevents split offset ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3c67fcc45d83. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
9143e22 to
6c14f42
Compare
|
Thanks for picking this up. The spool-before-offset ordering and the added poll/spool/offset diagnostics directly improve the original hazard reported in #113315. One important scope note before this PR closes the issue: a new current-main reproduction now shows an additional, confirmed signature after the durable-spool boundary. On This patch does not appear to change the claim/adoption → completion paths, so it may fix the first offset-before-spool failure mode without fixing the reproducible
A mandatory completion reason ( |
|
Reviewing current head
pending.then(
() => ackSpooledUpdate(duplicateRequestId, { ok: true, updateId }),
() => ackSpooledUpdate(duplicateRequestId, { ok: false, ... }),
)If the shared spool fails, the original request receives Reachability update after reading Suggested narrow fix: make the shared promise reject/rethrow after sending the original failure ACK, or have it resolve to an explicit success/failure result and map every coalesced request to that same result. Please add a regression that:
This is separate from the already-reported startup |
|
Live after-fix validation on the exact current head Each early sample used a clean container recreation and measured from the first isolated-worker
So the early result on the patched head is 2/3 silent losses, with a healthy late control on the same C3 instance. The pass between two losses also shows that this head has an intermittent startup race, not a uniformly fatal time window. The patch clearly improves the original spool-before-offset hazard: every tested update crossed the durable boundary before offset persistence, and the remaining loss is now durable and inspectable. But it does not resolve the separately confirmed startup Could the PR change Exact pre-dispatch completion map (source audit of this head)
A narrow diagnostic repair would make the handler return a mandatory discriminated outcome and persist it once at |
|
Correction to my post-PR reproduction analysis: the instrumented C2 loss was not a fresh-key startup race. The dropped DM was The V1 dispatch key is Therefore the post-PR Scope: this explains the |
25f45cd to
f7c0945
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer proof decision: accepting exact-head test confidence for the failure path, per ClawSweeper's documented option.
Skipping new exact-head live failure injection with that limitation recorded. Keeping #113315 open for its broader no-ingress investigation. |
|
@clawsweeper re-review |
…n isolated polling Closes openclaw#113315 In isolated polling ingress, the parent session now persists the Telegram update offset only after the update has been durably written to the spool. This prevents an update from being acknowledged (via the offset) before it has been safely enqueued, which could lead to permanent data loss if the process crashes between offset persistence and spool write. Changes: - Call persistUpdateId(updateId) after writeTelegramSpooledUpdate succeeds. - Add structured logs for poll-start, update receipt, spool success/failure, and offset persistence success/failure. - In isolated mode, stop passing onUpdateId to the bot so the offset is only persisted once, after the spool write. - Add regression tests verifying spool-before-offset ordering and the failure path when spooling fails.
… spooled updates Closes openclaw#113315 - Track successfully spooled update ids and advance the persisted offset only through a contiguous boundary. This prevents a later update_id from being persisted before an earlier one has finished spooling, which would make the earlier update unrecoverable after a restart. - Serialize spooling while no durable offset floor exists, so the first successful spool becomes the persisted floor. - Coalesce duplicate worker deliveries for the same update_id and ack both success and failure paths. - Fix TypeScript cast errors in polling-session.test.ts.
f7c0945 to
27de158
Compare
|
Merged via squash.
|
…n isolated polling (openclaw#113368) * fix(telegram): persist update offset only after durable spool write in isolated polling Closes openclaw#113315 In isolated polling ingress, the parent session now persists the Telegram update offset only after the update has been durably written to the spool. This prevents an update from being acknowledged (via the offset) before it has been safely enqueued, which could lead to permanent data loss if the process crashes between offset persistence and spool write. Changes: - Call persistUpdateId(updateId) after writeTelegramSpooledUpdate succeeds. - Add structured logs for poll-start, update receipt, spool success/failure, and offset persistence success/failure. - In isolated mode, stop passing onUpdateId to the bot so the offset is only persisted once, after the spool write. - Add regression tests verifying spool-before-offset ordering and the failure path when spooling fails. * fix(telegram): persist isolated polling offset only across contiguous spooled updates Closes openclaw#113315 - Track successfully spooled update ids and advance the persisted offset only through a contiguous boundary. This prevents a later update_id from being persisted before an earlier one has finished spooling, which would make the earlier update unrecoverable after a restart. - Serialize spooling while no durable offset floor exists, so the first successful spool becomes the persisted floor. - Coalesce duplicate worker deliveries for the same update_id and ack both success and failure paths. - Fix TypeScript cast errors in polling-session.test.ts. * fix(telegram): serialize durable polling offsets (openclaw#113368) --------- Co-authored-by: Carlos <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Refs #113315
What Problem This Solves
Isolated Telegram polling previously allowed the normal bot update tracker to persist an update offset before the ingress worker's durable spool write completed. A crash in that window could make Telegram stop redelivering an update that OpenClaw had not stored.
Changes
writeTelegramSpooledUpdatecommits.onUpdateIdcallback in isolated mode so each offset has one owner.Evidence
27de15889cbis rebased ontod4ed57bc884;git range-diffconfirms the reviewed patch series is unchanged.openclaw/ci-gatepassed: https://github.com/openclaw/openclaw/actions/runs/30247109038extensions/telegram/src/polling-session.test.tsproves spool → persist → ACK ordering and proves a spool failure produces no persisted offset or successful ACK.extensions/telegram/src/telegram-ingress-worker.runtime.test.tsproves the worker waits for each parent ACK before advancing the nextgetUpdatesoffset.