Repository navigation
Fix recovery of expired message reservations - #33
avlyubimov wants to merge 2 commits into
Conversation
Reviewer's GuideData structuresUse the reserved sorted set to represent active reservations and their expiration deadlines, enabling expired entries to be recovered without requeueing a reservation that has since changed.
APIAdd a positive, configurable reservation-timeout constructor argument with a 300-second default, preserving existing constructor calls.
ImplementationUpdate reservation processing and channel switching to preserve timeout configuration and safely coordinate expiry recovery with an ownership-checked mover lock.
DocumentationDocument the default and configurable reservation timeout, how it differs from the blocking read timeout, and the recovery fix.
TestsAdd integration and unit coverage for reservation deadlines, recovery, mover-lock ownership, timeout validation, and timeout preservation when changing channels.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. After the configured deadline, an unacknowledged message can be delivered again even if its original consumer is still processing it. That can run a handler twice and cause external side effects that reverting the code cannot undo.
samdark
left a comment
There was a problem hiding this comment.
Concurrent expiry recovery can redeliver a message while another consumer holds its fresh reservation. Please requeue only entries the recovery worker has exclusively reclaimed, and ensure only the lock owner can release the mover lock.
|
Thanks for catching this. Addressed in 4cd31c7:
Added deterministic regression tests for both races. All 36 tests pass locally on PHP 8.1 and 8.3. |
samdark
left a comment
There was a problem hiding this comment.
Please preserve PhpRedis value encoding across expiry recovery and lock cleanup, use a shared clock precise enough to honor the reservation timeout, handle reservation registration and Lua failures, document the Redis commands workers need, and keep only the initial release entry in the changelog.
What does this PR do?
When a consumer exits after
reserve()and beforedelete(), the message currently remains stranded:reserve()callszRem()instead of recording an expiration deadline. The recovery code therefore has no expired reservation to return to the waiting list.This change:
reservationTimeoutconstructor argument (300 seconds by default). Existing constructor calls remain valid.withChannelName()and documents the distinction between the reservation timeout and the blocking read timeout.Validation
The existing GitHub Docker build fails during Composer resolution of the development dependency set, before PHPUnit runs. Local validation used an isolated PHP 8.1/Redis setup with Infection omitted from the temporary test image, plus a PHP 8.3 image with
pcntlfor the consumer tests. This PR does not changecomposer.jsonor the package test infrastructure; mutation testing was not run.Scope
The reservation timeout must exceed the expected processing time; this change does not add a heartbeat or change acknowledgement semantics. It does not make the existing pop/deadline-registration sequence atomic, and messages stranded by older versions without a deadline are not repaired automatically.
Summary by Sourcery
Enable reliable redelivery of unacknowledged messages by tracking reservation expiration deadlines and recovering expired reservations safely.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: