docs: document mutex lock ownership caveat

This commit is contained in:
Shivam Mishra 2026-06-04 13:00:36 +05:30
parent 7066473e93
commit faca9cacde
No known key found for this signature in database

View File

@ -22,6 +22,11 @@ class MutexApplicationJob < ApplicationJob
end
end
# Redis::LockManager#unlock is not owner-checked. If a job runs past the TTL,
# Redis can expire the key, a newer job can acquire it, and the older job can
# then delete the newer job's lock on unlock. Current mutex users treat locks as
# short race dampeners, so this is acceptable for now. Future iterations should
# move Redis::LockManager to token-checked unlocks.
def with_lock(lock_key, timeout = Redis::LockManager::LOCK_TIMEOUT)
lock_manager = Redis::LockManager.new