-
Notifications
You must be signed in to change notification settings - Fork 897
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
Only remove my process' pidfile. #15491
Only remove my process' pidfile. #15491
Conversation
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.
Nice, simple change 👍 I tested on an appliance and verified it fixed the bug.
lib/pid_file.rb
Outdated
@@ -27,7 +27,7 @@ def remove | |||
def create(remove_on_exit = true) | |||
FileUtils.mkdir_p(File.dirname(@fname)) | |||
File.open(@fname, "w") { |f| f.write(Process.pid) } | |||
at_exit { PidFile.remove(@fname) } if remove_on_exit | |||
at_exit { PidFile.remove(@fname) if PidFile.new(@fname).pid == Process.pid } if remove_on_exit |
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.
Can this logic be pushed down into PidFile? Perhaps PidFile.remove!
or PidFile.safe_remove
?
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.
Gah...I didn't realize this was PidFile class 😖
Even so, what do you think of a different method to separate the concerns?
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.
We're in pidfile, let me try pushing it down to remove
9d39865
to
800c6e0
Compare
@@ -21,7 +21,7 @@ def pid | |||
end | |||
|
|||
def remove | |||
FileUtils.rm(@fname) if File.file?(@fname) | |||
FileUtils.rm(@fname) if pid == Process.pid |
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 pid method checks if the File exists... good idea @Fryguy
800c6e0
to
2134728
Compare
https://bugzilla.redhat.com/show_bug.cgi?id=1464698 at_exit handlers created in the server process are inherited when the server forks workers. As soon as one of these workers exits, this at_exit was being run and removing the server's pidfile. This allowed a subsequent rake evm:start or systemctl start evmserverd to fail to detect an existing server process, allowing a second MIQ Server to start. We can workaround this by only removing a pidfile that matches my Process.pid.
2134728
to
9090b3e
Compare
Checked commit jrafanie@9090b3e with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
…idfile Only remove my process' pidfile. (cherry picked from commit 8dff3ce) https://bugzilla.redhat.com/show_bug.cgi?id=1468612
Euwe backport details:
|
…idfile Only remove my process' pidfile. (cherry picked from commit 8dff3ce) https://bugzilla.redhat.com/show_bug.cgi?id=1478434
Fine backport details:
|
…idfile Only remove my process' pidfile. (cherry picked from commit 8dff3ce) https://bugzilla.redhat.com/show_bug.cgi?id=1484485
Darga backport details:
|
…rocess_pidfile Only remove my process' pidfile. (cherry picked from commit 8dff3ce) https://bugzilla.redhat.com/show_bug.cgi?id=1478434
https://bugzilla.redhat.com/show_bug.cgi?id=1464698
at_exit handlers created in the server process are inherited when the
server forks workers. As soon as one of these workers exits, this
at_exit was being run and removing the server's pidfile. This allowed a
subsequent rake evm:start or systemctl start evmserverd to fail to
detect an existing server process, allowing a second MIQ Server to
start.
We can workaround this by only removing a pidfile that matches my
Process.pid.