Use posix file advisory locks on supported platforms #295
Description
the current storage implementation uses a home brew approach to locking a file for a specific process.
this is a feature built into posix compatible filesystems.
certmagic filestorage should capability detect if posix locks are available, and if they are, use them to protect access to files.
advisory locks have two major weaknesses, that users of sqlite, mdbx, lmdb, are probably well familiar with.
- they do not work well on network filesystems (depends on implementation, very flaky regardless)
- you cannot use them to lock within a process - you still need mutex in process code to protect access to it.
#1 already exists as an issue in the current implementation
#2 can easily be dealt with by go's mutex.
as a result, I think that it would be good to incorporate this feature into certmagic storage.
that said, I don't use the filesystem module in production, so I don't really care that much. maybe someone who does would be happy to do this work :)
some resources:
https://gavv.net/articles/file-locks/
https://github.com/juju/fslock