Repository navigation
fix(queue): drop an owned Redis claim whose payload is gone instead of halting the reap sweep - #14481
Conversation
…f halting the reap sweep
|
Review complete. No issues found — approved ✅. This PR extends the queue package's Redis broker with message-abandon/recovery behavior implemented as a Lua script, plus an E2E test covering broker recovery semantics.
No issues met the reporting threshold; the change is approved. Reviewed commit: 94dd077 |
🟢 Tier S · Ready to mergeThe Redis reaper now atomically abandons owned claims when their payload is gone, provided the owner is unchanged and no heartbeat is live. Recovery tests cover dropping such an orphan while continuing the sweep, and preserving a payload-less claim whose handler is still active.
📂 Walkthrough · 3
Merged |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What
Broker\Redis::reap()no longer throws on a claim that still has its owner record but whose payload is gone. Such a claim has nothing left to requeue or park, so a newabandon.luadrops it atomically: it removes the pid from the processing list, deletes the owner record and decrements the processing counter. It does that only if the owner is unchanged, no heartbeat is live and the payload really is missing. A claim whose handler still heartbeats is left to that handler, sincecommitalready tolerates a missing payload.Why
Appwrite Cloud, fra1 (the last region still on Redis), Sentry CLOUD-3R40:
RuntimeException: Queue delivery payload is missing, 21K events, about one a minute from each ofworker-functions,worker-jobsandworker-webhooks, ongoing since about Oct 7.Two costs:
The orphans are claims whose payload expired while they were still owned. The existing comment allows for exactly that ("Only legacy payloads expire while processing"); only the ownerless case was handled.
Tests (
RedisBrokerRecoveryTest)maintestReapDropsAnOwnedClaimWhosePayloadIsGoneAndKeepsSweeping: two stranded claims, the first with its payload deleted. The sweep drops the orphan, requeues the second, clears the owner record and leaves the processing counter at 0RuntimeException: Queue delivery payload is missing(Redis.php:467)testReapLeavesAPayloadlessClaimWhoseHandlerIsAlive: with a live heartbeat, the claim stays until its handler commits itRun locally (
phpswoole/swoole:6.2.0-php8.5-alpine, Redis 7):RedisBrokerRecoveryTest22/22;RedisRejectTest,RedisCodecTestandRedisConnectionRecoveryTestgreen.RedisReservationTestandRedisExpiryTestfail only their Redis Cluster cases, identically onmain: no cluster was running locally.RedisAuthTest/RedisClusterDsnTestneed the auth Redis and the cluster from the package's compose; CI runs them.bin/monorepo validatepasses.The new tests sit at the end of the class on purpose: PHPStan's baseline names the anonymous class in
testReapToleratesAClaimSettledMidSweepby its line number, so inserting above it would shift that name and fail analysis.After deploy (Cloud fra1)
utopia-queue.processing.v1-{functions,jobs,webhooks}are cleared by the first sweep. Those deliveries were already unrecoverable; their payloads are gone.