fix(gateway): detect stopped processes and release stale locks on --replace - #2189
Closed
ygd58 wants to merge 1 commit into
Closed
fix(gateway): detect stopped processes and release stale locks on --replace#2189ygd58 wants to merge 1 commit into
ygd58 wants to merge 1 commit into
Conversation
Contributor
|
Merged via PR #2406. Cherry-picked with authorship preserved. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2178
Root Cause
Two bugs when
hermes gateway run --replaceencounters a STOPPED (Ctrl+Z) process:acquire_scoped_lock()treated stopped processes as alive —os.kill(pid, 0)succeeds for stopped processes, so stale lock files were never cleaned upstart_gateway()with--replaceremoved the PID file but not the scoped lock files in~/.local/state/hermes/gateway-locks/Fix (Option C: both fixes)
gateway/status.py — Option B:
os.kill(pid, 0)succeeds, check/proc/<pid>/statusfor process stateT(stopped) ort(tracing stop), treat as stale and clean up the lockgateway/status.py — Option A:
release_all_scoped_locks()function that removes all lock files in the lock directorygateway/run.py:
remove_pid_file()in--replacelogic, callrelease_all_scoped_locks()to clean up stale locks from the old gateway