Skip to content

feat: Clean up job IDs from dedup cache when resultTTL expires#37

Merged
mcollina merged 1 commit intomainfrom
feat/dedup-expiry
Mar 8, 2026
Merged

feat: Clean up job IDs from dedup cache when resultTTL expires#37
mcollina merged 1 commit intomainfrom
feat/dedup-expiry

Conversation

@mcollina
Copy link
Member

@mcollina mcollina commented Mar 5, 2026

Summary

  • Job dedup entries now expire when resultTTL elapses, allowing the same job ID to be re-enqueued after its result has been garbage collected
  • Uses a companion expiry field ({id}:exp in Redis, #jobExpiry map in Memory, {id}.ttl file in File) to track when terminal job entries should expire
  • updateResultTTL also syncs the dedup expiry window when extending result TTL

Test plan

  • New dedup expiry tests: re-enqueue after completed job TTL expires, re-enqueue after failed job TTL expires, dedup still blocks within TTL window, getJobState returns null after expiry
  • Existing dedup tests still pass (dedup works within TTL window)
  • Updated updateResultTTL test: expects not_found instead of missing_payload after TTL expiry (job state is now cleaned up)
  • All 149 non-Redis tests pass

🤖 Generated with Claude Code

Job entries in the jobs hash previously persisted forever, even after
the result/error TTL expired. This meant a completed job's ID could
never be reused. Now deduplication lasts only as long as the result is
cached — once resultTTL expires, the job ID is cleaned up so it can be
re-enqueued.

Uses a companion expiry field ({id}:exp in Redis, #jobExpiry map in
Memory, {id}.ttl file in File) to track when terminal job entries
should expire. On enqueue, if the existing job has expired, it is
deleted and re-enqueue proceeds. The updateResultTTL method also syncs
the dedup expiry when extending the result TTL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mcollina mcollina requested a review from ShogunPanda March 6, 2026 15:51
Copy link

@marcopiraccini marcopiraccini left a comment

Choose a reason for hiding this comment

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

Looks OK

@mcollina mcollina merged commit b404f47 into main Mar 8, 2026
1 check passed
@mcollina mcollina deleted the feat/dedup-expiry branch March 8, 2026 14:58
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.

3 participants