Repository navigation
Description
OpenClaw version: 2026.6.10
Channel: Telegram (long-polling / isolated ingress mode)
Storage: channel_ingress_events table in state/openclaw.sqlite
Summary
Inbound messages stop being delivered to the agent after the gateway is restarted while a worker has an in-flight claimed row in channel_ingress_events. The claim is never released, so the stuck rows block all subsequent pending events on the same queue indefinitely. The agent keeps polling and reports healthy, but never processes or replies to any incoming message.
This is a classic stale-claim / orphaned-lease bug: the queue has no visibility-timeout or reaper to recover claims owned by a dead worker.
Impact
- Agent appears fully healthy:
/readyand/healthreturn OK, Telegram polling logs showisolated polling ingress started, no errors. - Telegram side shows
pending_update_count: 0(updates are fetched), but the agent never emits anInbound messagelog and never replies. - Every message sent after the stuck claim is silently queued as
pendingand never dispatched. - Symptom is indistinguishable from "channel broken" at the surface;
openclaw doctor --lintdoes not detect it (config is valid; the failure is purely at the runtime queue layer).
Root cause
channel_ingress_events lifecycle: pending → claimed (worker takes it) → completed (purged) / failed.
When a worker claims an event (status='claimed', sets claim_token/claim_owner/claimed_at) and the gateway process is then killed mid-flight (SIGKILL, container restart, resource resize), the row stays claimed forever. On restart, a new worker does not reclaim these orphaned rows, and they sit ahead of newer pending rows in the queue ordering, blocking delivery.
The table schema already carries everything needed to detect this (claimed_at, attempts, last_attempt_at) — there is simply no logic that releases claims older than a timeout.
Reproduction (observed in production)
- Agent (Telegram, isolated polling ingress) is actively processing.
- Container is restarted abruptly (in our case: an orchestrator
stop → resize → startsequence, plus a few manual restarts during debugging) while several events wereclaimed. - After restart: polling resumes cleanly, no conflict, healthy — but agent never processes any inbound message.
Observed DB state (40 stuck rows for one telegram queue):
status='claimed' count=31 (all claim_owner='7:239da3b5-...', claimed_at≈resize time, attempts=0, last_error=NULL)
status='pending' count=9 (every message the user sent afterwards, never dispatched)
All 31 claimed rows were owned by a single dead worker id; none ever advanced to completed. Telegram offset on the API side had advanced past them (updates fetched), but the agent never saw them because they were stuck in the local DB queue.
Workaround used
DELETE FROM channel_ingress_events
WHERE channel_id = 'telegram'
AND status IN ('claimed', 'pending');After clearing the stuck rows and restarting, the new worker claimed → dispatched → completed normally (Inbound message logged, outbound send ok, queue back to empty).
Suggested fix
Add stale-claim recovery to the channel_ingress_events consumer, e.g. any of:
- Visibility timeout / claim TTL — on claim acquisition, reset rows where
status='claimed' AND claimed_at < now() - CLAIM_TTL_MSback topending(clearclaim_token/claim_owner), bumpattempts. - Startup reaper — on gateway boot, release all
claimedrows whoseclaim_ownerdoesn't match a live worker (workers are short-lived per-process, so any pre-restart claim is by definition orphaned). - Worker heartbeat / lease renewal — require periodic claim renewal; expired leases auto-release.
Option (2) alone (release-on-boot) would have fully prevented this case, since a restart guarantees the previous claim owner is dead.
Optionally: have openclaw doctor surface a warning when channel_ingress_events has claimed rows with claimed_at older than N minutes — this would have made diagnosis immediate.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 24, 2026
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.
Close as a duplicate: the report is the same SQLite
channel_ingress_eventsstale-claim deadlock already tracked by the older open canonical issue, with an open candidate PR for the shared startup recovery fix.Root-cause cluster
Relationship:
duplicateCanonical: #90945
Summary: This issue is a duplicate of the canonical open SQLite
channel_ingress_eventsstale-claim recovery report; the same durableclaimedrows block later Telegram delivery after restart.Members:
canonical: channel_ingress_events (SQLite): stale claims never recovered after session crash — Telegram DM deadlocks #90945 - It is older, open, source-reproducible, and describes the same SQLite stale claimed-row deadlock with pending Telegram messages behind it.fixed_by_candidate: fix(channels): recover stale ingress queue claims at gateway startup #90989 - The open PR uses closing syntax for the canonical issue and implements a startup sweep for stalechannel_ingress_eventsclaims.duplicate: channel_ingress_events: claimed events never released when worker/session dies (no TTL or heartbeat) #90940 - The closed earlier report describes the samechannel_ingress_eventsclaimed-row deadlock when worker/session ownership dies.duplicate: [Bug]: Telegram ingress queue can become permanently blocked after gateway restart #91670 - The closed report has the same Telegramchannel_ingress_eventsclaimed/pending backlog after gateway restart.duplicate: Telegram inbound permanently deadlocked after unclean exit: ingress queue head claim has no TTL/reclaim (head-of-line block, zero logs) #92259 - The closed report describes Telegram inbound deadlock behind an unreclaimed ingress queue claim after unclean exit.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Canonical path: Keep #90945 as the canonical tracker and review, land, or close #90989 after maintainer validation.
So I’m closing this here and keeping the remaining discussion on #90945 and #90989.
Review details
Best possible solution:
Keep #90945 as the canonical tracker and review, land, or close #90989 after maintainer validation.
Do we have a high-confidence way to reproduce the issue?
Yes at source level: current main keeps claimed rows out of pending replay and has only queue-local recovery hooks, while the report and canonical issue provide matching production DB states. I did not run a live crash/restart reproduction in this read-only review.
Is this the best way to solve the issue?
Yes: duplicate close is the best triage path because the fix belongs in shared channel/gateway SQLite ingress recovery and is already represented by the canonical issue and open candidate PR.
Security review:
Security review: No patch is under review, and the report is not itself a security disclosure.
AGENTS.md: found and applied where relevant.
What I checked:
AGENTS.md:1, bfffc77bfc86)pendingrows separately fromclaimedrows, matching the reported durable queue state where claimed rows do not return to pending without recovery. (src/channels/message/ingress-queue.ts:401, bfffc77bfc86)recoverStaleClaims()only lists claims for one constructed queue, andclaimNext()invokes it only when a caller passesstaleMs; no global startup recovery helper exists on current main. (src/channels/message/ingress-queue.ts:443, bfffc77bfc86)channel_ingress_eventsstale-claim sweep before channels start. (src/gateway/server-startup-plugins.ts:62, bfffc77bfc86)runStartupIngressClaimSweeporrecoverAllStaleChannelIngressClaims, so this is not already fixed in the latest release. (src/gateway/server-startup-plugins.ts:65, aa69b12d0086)claimed/pendingSQLite ingress deadlock, and fix(channels): recover stale ingress queue claims at gateway startup #90989 is the open closing implementation candidate for that canonical issue.Likely related people:
refactor(channels): store inbound queues in SQLite, the durable storage path involved in this report. (role: introduced shared queue storage; confidence: high; commits: b0679d1f13da; files:src/channels/message/ingress-queue.ts,src/state/openclaw-state-schema.sql,extensions/telegram/src/telegram-ingress-spool.ts)src/channels/message/ingress-queue.ts,extensions/telegram/src/telegram-ingress-spool.ts)src/channels/message/ingress-queue.ts,src/gateway/server-startup-ingress-sweep.ts,src/gateway/server-startup-plugins.ts)extensions/telegram/src/telegram-ingress-spool.ts,extensions/telegram/src/polling-session.ts)Codex review notes: model internal, reasoning high; reviewed against bfffc77bfc86.