Repository navigation
Description
In short: A rejected job keeps its payload in Redis with no TTL, and nothing ever removes failed jobs.
queue-retryis the only tool, and it brings back jobs of any age.Impact:
- Every outage leaves its failed jobs in Redis for good: 133 422
v1-stats-usagejobs from one three-week window on our instance, plus 6 318 inv1-jobsand 2 340 inv1-executions.- With
allkeys-lruthey take memory from the cache and the live queues (see 🐛 Bug Report: Usage queue backlog evicts the cache from Redis #14084).
👟 Reproduction steps
-
Self-hosted Appwrite 2.7.2. Make any queue reject jobs, e.g. stop ClickHouse for a minute while usage is written, or deploy sites on several nodes (lock contention in
v1-jobs, separate issue). -
Check the failed list and a payload:
docker exec appwrite-redis redis-cli llen utopia-queue.failed.v1-stats-usage pid=$(docker exec appwrite-redis redis-cli lindex utopia-queue.failed.v1-stats-usage -1) docker exec appwrite-redis redis-cli ttl utopia-queue.jobs.v1-stats-usage.$pid
👍 Expected behavior
Failed jobs are kept for a bounded time for inspection and queue-retry, then removed, or there is a task to purge failed jobs older than a given age.
👎 Actual Behavior
The failed lists only grow; every payload has TTL -1. Our oldest entries are four weeks old.
Cause: on reject, settle.lua pushes the pid onto utopia-queue.failed.<queue>, keeps the payload in utopia-queue.jobs.<queue>.<pid> and only sets EXPIRE when the queue's jobTtl is greater than 0 (settle.lua L28–L29). The worker server builds its queues with new Queue($queueName, $namespace) (Server.php L525), so jobTtl is 0 (Queue.php L12). maintain()/reap() only handle stuck claims, and the maintenance task does not touch queues.
The CLI does not help either:
queue-retry --name=<queue>requeues every failed job regardless of age. Forv1-jobsthat appends old log lines to long finished deployments, forv1-stats-usageit books weeks old usage again.bin/queue-count-failedcalls aqueue-counttask that is not registered inServices/Tasks.php.GET /v1/health/queue/failed/:namedoes not knowv1-jobsandv1-executions(🐛 Bug Report:GET /v1/health/queue/failed/:namerejects thev1-executionsandv1-jobsqueues #14632, closed as not planned).
Why it matters: an operator cannot see, bound or clean up failed jobs without writing Redis scripts, and the only safe way to delete them is pid by pid (LREM plus DEL of the payload), because the payloads of running jobs share the same key prefix.
Related: #14084 (Redis eviction), #14491 (payloads left by queue-retry, fixed in 2.7.2).
🎲 Appwrite version
2.7.3 (measured on 2.7.2, code unchanged in 2.7.3)
💻 Operating system
Linux (Ubuntu 26.04), Docker
🧱 Your Environment
Self-hosted, three API nodes and one database node, Redis 7.4 with allkeys-lru shared by cache and queues.
💡 Suggested fix
- Give worker queues a retention for failed jobs (e.g.
jobTtlof 7 days for the payload, and trim the failed list inmaintain()), configurable by an environment variable. - Add
queue-purge --name=<queue> --older-than=<days>next toqueue-retry, and an age filter forqueue-retry(the broker'sretry()already supportsnewerThan). - Fix or remove
bin/queue-count-failed.
👀 Have you spent some time to check if this issue has been raised before?
- I checked and didn't find a similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct
Activity