Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
init: Keep track of whether data directory locked, don't cleanup if not #10818
Conversation
laanwj
added the
Bug
label
Jul 13, 2017
laanwj
added this to the
0.15.0
milestone
Jul 13, 2017
|
This seems right to me and it solved the problem, but I'm not confident enough in understanding startup/shutdown to actually give it an ACK. Thanks! |
MeshCollider
commented
Jul 13, 2017
|
utACK 73b6b4e |
|
utACK 73b6b4e |
|
utACK 73b6b4e |
|
Why not just make AppInitSanityCheck actually take the lock instead of just probing? It seems strange to call the entire shutdown sequence instead when literally none of it is needed when we already have a framework for skipping it (ala if AppinitSanityCheck fails, except for GUI, which really should be fixed in GUI, not by adding a boolean). |
|
@TheBlueMatt I'm confused how that would help here. |
|
My point is that this is (effecitlvely) not a problem in bitcoind. The issue in bitcoin-qt is that it calls Shutdown() where it should not (and bitcoind does not). If we want to separately fix the race that is also present in bitcoind, we should stop doing this strange LockDataDirectory(true)...one function return/call later...LockDataDirectory(false) thing. |
| @@ -75,6 +75,9 @@ static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; | ||
| std::unique_ptr<CConnman> g_connman; | ||
| std::unique_ptr<PeerLogicValidation> peerLogic; | ||
| +/** Set at startup if the data directory was succesfully locked */ | ||
| +bool g_locked_data_directory = false; |
laanwj
Jul 15, 2017
Owner
static ok, atomic no, there's no concurrent modification as the flag is set from one place in the initialization sequence.
The point, which I explain in #10815 (comment), is that that mechanism ALSO doesn't work for bitcoind.
The point of that 'strange sequence' is to be able to give a proper error in the case of Do you mean calling LockDataDirectory in a separate initialization step after daemonizing? That could work, though as it is already so easy to introduce bugs like this I thought it was more robust to add a flag. |
laanwj
added a commit
to laanwj/bitcoin
that referenced
this pull request
Jul 15, 2017
|
|
laanwj |
ceec6cb
|
laanwj
referenced
this pull request
Jul 15, 2017
Merged
init: Factor out AppInitLockDataDirectory and fix startup core dump issue #10832
|
Closign in favor of #10832 |
laanwj
closed this
Jul 15, 2017
laanwj
added a commit
to laanwj/bitcoin
that referenced
this pull request
Jul 17, 2017
|
|
laanwj |
dba485d
|
laanwj
added a commit
that referenced
this pull request
Jul 17, 2017
|
|
laanwj |
89bb036
|
laanwj commentedJul 13, 2017
•
edited
Keep a flag in
init.cppindicating whether the data directory was locked.If not, Interrupt and Shutdown are no-ops. This avoids things from being cleaned up if they were created by another instance.
I think this is the most robust, sure solution to #10815.
n.b.: We can't simple do "don't call Interrupt/Shutdown if Init*() failed" because some of the things needs to be interrupted and shut down in case of an error later in initialization when some things have already been started.