Open drltc opened 9 years ago
This error is actually not directly related to having 2 clients open, but was a bug that could show up in other circumstances as well: https://github.com/BitShares/bitshares/commit/3930bfef2ba30977250b1df01af21fc74122dcd3
We do need a way to prevent multiple clients from being open, however.
I forgot I had a client reindexing, and I opened a copy of the GUI:
~/bitshares/build (bitshares ✘)✹ ᐅ ./programs/client/bitshares_client --rebuild-index
Loading config from file: /Users/vikram/Library/Application Support/BitShares/config.json
Using blockchain checkpoints from file: /Users/vikram/Library/Application Support/BitShares/checkpoints.json
Erasing all state
Initializing state from built-in genesis file
Please be patient, this will take several minutes...
Replaying blockchain... Approximately 16.69% complete.------------ error --------------
10000 level_map_failure: level_map failure
database error: IO error: /Users/vikram/Library/Application Support/BitShares/chain/index/fork_db/000045.log: No such file or directory
{"msg":"IO error: /Users/vikram/Library/Application Support/BitShares/chain/index/fork_db/000045.log: No such file or directory"}
th_a level_map.hpp:361 store
error storing c150b5f0b7279f00cff17043f13ba4dc9d6a15af = {"next_blocks":[],"is_linked":true,"is_valid":null,"invalid_reason":null,"is_included":false,"is_known":true}
{"key":"c150b5f0b7279f00cff17043f13ba4dc9d6a15af","value":{"next_blocks":[],"is_linked":true,"is_valid":null,"invalid_reason":null,"is_included":false,"is_known":true}}
th_a level_map.hpp:363 store
{"block_id":"c150b5f0b7279f00cff17043f13ba4dc9d6a15af"}
th_a chain_database.cpp:657 store_and_index
{"block_data":{"previous":"9d481fc03bb8c59084ef74b225e44b460dddbf59","block_num":291736,"timestamp":"2014-08-22T22:21:20","transaction_digest":"c8cf12fe3180ed901a58a0697a522f1217de72d04529bd255627a4ad6164f0f0","next_secret_hash":"5b498bfbef87888147858c22f45a3d1767de7733","previous_secret":"2bd31a26eff63a65a2b59a2dcccc318d5d44238b","delegate_signature":"1f1f6b206eb656b416e248f0458d96e79893061e01d92b29bce004b4af243b9d7ec3c186aa4fa429bf5e5cf0c2c54f1b722e67e873508dfdf7f07590d36d5fa5f7","user_transactions":[]}}
th_a chain_database.cpp:1802 push_block
{"data_dir":"/Users/vikram/Library/Application Support/BitShares/chain"}
th_a chain_database.cpp:1484 open
{"data_dir":"/Users/vikram/Library/Application Support/BitShares"}
th_a client.cpp:1346 open
I get this error when accidentally running two clients with the same datadir:
We should explicitly check if a client is running and print a nice error message, instead of an ugly exception report. I am thinking Boost file lock on a file in the data directory should do the trick: http://www.boost.org/doc/libs/1_57_0/doc/html/interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.file_lock
It claims the lock is released by the OS if we crash, so if the "am I already running?" logic is implemented with this, it should robustly give the right answer even if the previous process crashed.
Alternatively we could just catch and wrap the exception that's already being thrown.