-
Notifications
You must be signed in to change notification settings - Fork 9
fix: release periodic lock when no active checkers exist #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1735,6 +1735,23 @@ function _M.new(opts) | |
| expire = function() | ||
|
|
||
| if get_periodic_lock(shm, key) then | ||
| -- Check if there are any active checkers before renewing the lock. | ||
| -- When all checkers have been stopped (active=false), the lock holder | ||
| -- must release the lock so that other workers with active checkers | ||
| -- can acquire it. | ||
| local has_active_checker = false | ||
| for _, checker_obj in pairs(hcs) do | ||
| if checker_obj.checks.active.healthy.active or | ||
| checker_obj.checks.active.unhealthy.active then | ||
| has_active_checker = true | ||
| break | ||
| end | ||
| end | ||
| if not has_active_checker then | ||
| shm:delete(key) | ||
| active_check_timer.interval = CHECK_INTERVAL * 10 | ||
| return | ||
| end | ||
| active_check_timer.interval = CHECK_INTERVAL | ||
| renew_periodic_lock(shm, key) | ||
|
Comment on lines
1737
to
1756
|
||
| else | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The early return when
has_active_checkeris false skips the periodic cleanup section below (purging targets withpurge_timeset bydelayed_clear). This can leave delayed-clear state in shm indefinitely whenever active checks are disabled/stopped across all checkers on the lock-holding worker. Consider running the cleanup logic before releasing the periodic lock (or making the “no active checker” condition account for pendingpurge_timework) sodelayed_clearstill completes even when active checks are turned off.