post icon indicating copy to clipboard operation
post copied to clipboard

lock files in post data directory when accessing

Open fasmat opened this issue 2 years ago • 0 comments

Description

At the moment no checks are in place that prevent multiple processes (go-spacemesh, postcli, etc.) from accessing the same data directory simultaneously. This can be dangerous, especially if at least one of those processes is modifying the data (resizing, initializing, etc.). post should be updated such that only one process can access the dataDir at a time.

Acceptance criteria

  • A file lock protects access to the dataDir
  • Multiple processes that access the data read-only may do that simultaneously (i.e. a running node and verifying data integrity with postcli)
  • Multiple processes that modify/update data must not be able to access the dataDir at the same time. At most once process should be able to get an exclusive lock while the others should communicate an error to the user that a different process is accessing the data at the moment (e.g. postcli cannot modify the dataDir while the node is running)
  • Consider if long running processes that modify data (e.g. postcli init, postcli resize) do that in a manner that allows reading processes to access existing data.
    • For instance initialization / resize could create new files in a sub directory while a node is running and inform the user to shut down the node just for the last step where the newly created files are moved to the main directory and the metadata is updated.

fasmat avatar Jul 28 '23 09:07 fasmat