Skip to content
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

chain_data/grin.lock to prevent multiple grin processes running from same dir #2600

Merged
merged 1 commit into from
Feb 19, 2019

Conversation

antiochp
Copy link
Member

@antiochp antiochp commented Feb 19, 2019

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

../target/release/grin server run
Failed to lock "/antiochp/grin/node_mainnet/chain_data/grin.lock" (grin server already running?)

This will prevent multiple grin server instances from being run (accidentally or otherwise) from the same chain_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...

File locks are implemented with flock(2) on Unix and LockFile on Windows.

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

@antiochp antiochp self-assigned this Feb 19, 2019
@antiochp antiochp added this to the 1.0.2 milestone Feb 19, 2019
@antiochp antiochp merged commit 48b7421 into mimblewimble:master Feb 19, 2019
@antiochp antiochp deleted the one_grin_at_a_time branch February 19, 2019 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants