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

Use posix file advisory locks on supported platforms #295

Open
elee1766 opened this issue Jun 21, 2024 · 1 comment
Open

Use posix file advisory locks on supported platforms #295

elee1766 opened this issue Jun 21, 2024 · 1 comment
Labels
feature request Request for new feature or functionality

Comments

@elee1766
Copy link
Contributor

elee1766 commented Jun 21, 2024

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.

  1. they do not work well on network filesystems (depends on implementation, very flaky regardless)
  2. 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

@elee1766 elee1766 added the feature request Request for new feature or functionality label Jun 21, 2024
@mholt
Copy link
Member

mholt commented Jul 15, 2024

This could be a good idea. As mentioned in Slack, I don't know much about them, so I'm not sure I'd be the right person to implement or review this patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for new feature or functionality
Projects
None yet
Development

No branches or pull requests

2 participants