Skip to content

fix(worker): reclaim stale tasks from dead workers - #992

Closed
r266-tech wants to merge 2 commits into
vectorize-io:mainfrom
r266-tech:fix/reclaim-stale-worker-claims
Closed

fix(worker): reclaim stale tasks from dead workers#992
r266-tech wants to merge 2 commits into
vectorize-io:mainfrom
r266-tech:fix/reclaim-stale-worker-claims

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Summary

When a worker dies without graceful shutdown (OOM-killed, node failure, container restart with new hostname), its claimed async_operations rows stay in processing indefinitely. The existing recover_own_tasks only recovers tasks for the same worker_id, which doesn't help when a container restarts with a new hostname.

Because consolidation uses per-bank serialization (NOT EXISTS ... status='processing'), stale claims also block all new work on affected banks — the live worker sees slots occupied by a dead hostname and never claims pending tasks.

Changes

  • Add reclaim_stale_tasks() method to WorkerPoller that periodically resets tasks from other workers when claimed_at exceeds a configurable timeout (default 15 minutes)
  • Own in-flight tasks are never touched (worker_id IS DISTINCT FROM $2)
  • Reclamation runs at most once per 60 seconds (not every poll tick)
  • New stale_claim_timeout_minutes constructor parameter (set to 0 to disable)
  • 4 focused tests covering: stale reclaim, recent-claim safety, own-task safety, disable path

Root cause (from #991)

async_operations WHERE status='processing' AND worker_id='<dead hostname>'

→ never reclaimed → per-bank serialization blocks new work → bank permanently wedged

Manual UPDATE ... SET status='pending' WHERE worker_id='<dead>' immediately unblocks the bank (confirmed by reporter).

Fixes #991

r266-tech and others added 2 commits April 12, 2026 00:14
When a worker dies without graceful shutdown (OOM-killed, node failure,
container restart), its claimed async_operations rows stay in
'processing' indefinitely. Because consolidation uses per-bank
serialization, stale claims also block all new work on affected banks.

The existing recover_own_tasks only recovers tasks for the same
worker_id, which doesn't help when a container restarts with a new
hostname.

Add a periodic reclaim_stale_tasks pass to the polling loop that
resets tasks from other workers when claimed_at exceeds a configurable
timeout (default 15 minutes). Own in-flight tasks are never touched.

Fixes vectorize-io#991

@nicoloboschi nicoloboschi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want to implement this for now. we need to figure out why workers are stuck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale claimed_at not reclaimed after worker crash — operations stuck in 'processing' forever

2 participants