7

Is there any difference in how the save and exit commands save the blockchain?

Is there any benefit in using the save command before using exit to close bitmonerod?

What is the danger is closing monerod without saving because my computer froze up, or my laptop battery died, etc? Is a failure to save new blocks since the prior save the worst that could happen or is data corruption also possible?

8

Saving isn't really needed now. All it does is call mdb_env_sync, which will flush the filesystem, so the OS really writes things on the disk. Exiting bitmonerod normally will also call this, so using save before exit is unneeded.

Originally, save was needed because the blockchain was all held in RAM, so if your node was running long term and crashed, you'd lose days or weeks or even months of sync time. This is not the case anymore, and the use of LMDB means any changes are reflected on disk automatically (that is, depending on whether the OS decides to keep certain pages in its disk cache, and this is where mdb_env_sync comes into play).

Ideally, there should not be corruption if bitmonerod crashes. I don't know the details of db transactions though, so if you can, always exit gracefully, but if you can't, it should usually be OK. However, there have been reports of failing to start back up, which I've not seen here when killing bitmonerod abruptly, so better safe than sorry.

  • 3
    Safety is controlled by the --db-sync-mode option. The default is fastest:async:1000 which can corrupt data in a system crash. You should use safe:sync if you're concerned about system crashes. There is never any risk of corruption from just the bitmonerod process crashing (with the rest of the system still running OK). When I'm testing various builds, I use "kill -9" on bitmonerod when I want it to stop immediately, without waiting for mdb_env_sync. – hyc Aug 9 '16 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.