chain_data/grin.lock to prevent multiple grin processes running from same dir #2600
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uses fs2 to take an advisory file lock. Should work across platforms (*nix & windows).
https://docs.rs/fs2/0.4.3/fs2/trait.FileExt.html#tymethod.try_lock_exclusive
This will prevent multiple
grin server
instances from being run (accidentally or otherwise) from the samechain_data
dir.This is believed to be one way a node can corrupt the backend files (two grin instances both writing to the same files).
This is new to me. I had no idea what a file lock really was... thought it was just creating a file and looking for the existence of said file...
http://man7.org/linux/man-pages/man2/flock.2.html
Somewhat related - going down the rabbit hole here - https://gavv.github.io/articles/file-locks/#bsd-locks-flock