-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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
rpc: keep .cookie
file if it was not generated
#28784
Conversation
Otherwise, starting bitcoind twice may cause the `.cookie` file generated by the first instance to be deleted by the second instance shutdown (after failing to obtain a lock).
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
The bug can be reproduced manually by starting
|
.cookie
file if it was not generated
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.
utACK, though it might be better to do something like keep the file open and detect if it's the same file/content before we delete it.
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.
utACK 7cb9367
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.
utACK after squash
Otherwise, starting bitcoind twice may cause the `.cookie` file generated by the first instance to be deleted by the second instance shutdown (after failing to obtain a lock). Github-Pull: bitcoin#28784 Rebased-From: 7cb9367
Github-Pull: bitcoin#28784 Rebased-From: ad37ad4
ad37ad4
to
d95dde9
Compare
Thanks for the review! |
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.
re-ACK d95dde9
re-ACK d95dde9 |
Otherwise, starting bitcoind twice may cause the `.cookie` file generated by the first instance to be deleted by the second instance shutdown (after failing to obtain a lock). Github-Pull: bitcoin#28784 Rebased-From: d95dde9
Just wanted to ask whether there are any other outstanding issues? :) |
Ping :) |
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.
ACK d95dde9
Kind of suprised this wasn't noticed earlier, but thanks for the patch!
I also noticed while testing this that the same issue is present with the pid file, but I will open a seperate pull for that in a moment.
lgtm ACK d95dde9 |
d95dde9
to
9133b20
Compare
Note: If you revert to 7cb9367 instead (which is the same), the previous reviews will be valid again |
9133b20
to
7cb9367
Compare
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.
re-ACK 7cb9367
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.
ACK 7cb9367
@@ -131,7 +134,10 @@ bool GetAuthCookie(std::string *cookie_out) | |||
void DeleteAuthCookie() | |||
{ | |||
try { | |||
fs::remove(GetAuthCookieFile()); | |||
if (g_generated_cookie) { |
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.
nit: can be done without extra nesting
git diff on 7cb9367
diff --git a/src/rpc/request.cpp b/src/rpc/request.cpp
index b7acd62ee3..ad9f244f12 100644
--- a/src/rpc/request.cpp
+++ b/src/rpc/request.cpp
@@ -133,11 +133,10 @@ bool GetAuthCookie(std::string *cookie_out)
void DeleteAuthCookie()
{
+ // Don't delete the cookie file if it wasn't generated by this process
+ if (!g_generated_cookie) return;
try {
- if (g_generated_cookie) {
- // Delete the cookie file if it was generated by this process
- fs::remove(GetAuthCookieFile());
- }
+ fs::remove(GetAuthCookieFile());
} catch (const fs::filesystem_error& e) {
LogPrintf("%s: Unable to remove random auth cookie file: %s\n", __func__, fsbridge::get_filesystem_error_message(e));
}
re-ACK 7cb9367 |
ACK 7cb9367 |
Thanks :) |
8f6ab31 init: don't delete PID file if it was not generated (willcl-ark) Pull request description: In a similar vein to #28784, if a second `bitcoind` is started using the same datadir it will fail to start up, but during shutdown remove the PID file from the first `bitcoind` instance. ACKs for top commit: achow101: ACK 8f6ab31 andrewtoth: ACK 8f6ab31 romanz: ACK 8f6ab31 Tree-SHA512: c9af703cbfa179d33ef9580a51e86c1b0acbd28daa18c8d2e5e5ff796ab4d3e2009a962a47e6046a0e5ece936f8a06ee8af5fdf8ff4ae1e52cbcdbec4b942271
Otherwise, starting bitcoind twice may cause the `.cookie` file generated by the first instance to be deleted by the second instance shutdown (after failing to obtain a lock). Github-Pull: bitcoin#28784 Rebased-From: 7cb9367
Github-Pull: bitcoin#28784 Rebased-From: d95dde9
Otherwise, starting bitcoind twice may cause the `.cookie` file generated by the first instance to be deleted by the second instance shutdown (after failing to obtain a lock). Github-Pull: bitcoin#28784 Rebased-From: 7cb9367
… generated") 1e95643 rpc: keep .cookie if it was not generated (Roman Zeyde) Pull request description: v26 introduced a regression in that starting a `bitcoind` twice may have the second instance delete the cookie file of the first, making it impossible to communicate with it. Not a big deal but it's annoying, only an issue for 26.0, and the patch is trivial. ACKs for top commit: glozow: lgtm ACK 1e95643 Tree-SHA512: 0e4b18aebaaf284944f1709b238c8c0acce5e8997409e0c278a5a30ac221ac1ff1d3ad31fbf2ac15b03bf7582891e07a7a2cf00f13cb596aa9512566b9320c23
this was backported for 26.x in #29503 |
Github-Pull: bitcoin#28784 Rebased-From: d95dde9
Github-Pull: bitcoin#28784 Rebased-From: d95dde9
Otherwise, starting bitcoind twice may cause the
.cookie
file generated by the first instance to be deleted by the second instance shutdown (after failing to obtain a lock).