You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(redis): the monitoring and operator-queue leader leases release with GET-then-DELETE #4253
MonitoringService._release_leadership (services/monitoring_service.py:999, monitoring:leader) and the operator-queue poller's _release_leadership (services/operator_queue_service/poller.py:139, opqueue:leader) do this:
if r.get(KEY) == self._worker_id:
r.delete(KEY)
If our lease lapses after the GET and a sibling worker wins SET NX, the DELETE removes the sibling's lease. A third worker can then acquire while the sibling still believes it leads, so two cycles run at once. The canary leader lease closed this window for itself in #1881, and its comment (services/canary_service.py, the lease block) names these two leases as sharing the old shape.
With trinity#4028 (PR #4251) the atomic release script has one home: redis_breaker_util.LEASE_RELEASE_LUA, which the canary also uses.
What must be true
Neither leader-lease release can delete a sibling's lease, including when the sibling wins between a client-side read and the delete.
Their refresh, if they have one, gets the same check.
Tested against an executing-script emulator, not a Python copy of the compare.
One more lease with the same race, found while reviewing #4251: the sync-health poll lease (src/backend/services/sync_health_service.py). It keeps its own copy of the release script, and its refresh is GET-then-EXPIRE (around lines 458-459), so a stale worker can re-arm its successor's lease and both act as leader. It fits here with the other leader leases.
Adding one more lease to this issue's scope. PR #4251's description says the sync-health poll lease belongs here, and this issue's text did not mention it: services/sync_health_service.py keeps its own copy of the release script, and its refresh is GET-then-EXPIRE. That is the same race #4028 closes for SingleFlightLock, so it should move to the shared scripts with the two leader leases.
Activity
AndriiPasternak31 commentedon Nov 4, 2026
One more lease with the same race, found while reviewing #4251: the sync-health poll lease (
src/backend/services/sync_health_service.py). It keeps its own copy of the release script, and its refresh is GET-then-EXPIRE (around lines 458-459), so a stale worker can re-arm its successor's lease and both act as leader. It fits here with the other leader leases.vybe commentedon Nov 5, 2026
Adding one more lease to this issue's scope. PR #4251's description says the sync-health poll lease belongs here, and this issue's text did not mention it:
services/sync_health_service.pykeeps its own copy of the release script, and its refresh is GET-then-EXPIRE. That is the same race #4028 closes forSingleFlightLock, so it should move to the shared scripts with the two leader leases.