caddyserver / caddyserver/certmagic
Use posix file advisory locks on supported platforms
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 5.6k
- Forks
- 354
- Avg merge
- 9d 23h
- Merged PRs (30d)
- 3
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the certmagic filestorage implementation and its current file-locking path. Read the linked file-lock resources and determine how supported platforms can be detected; done means POSIX advisory locks protect file access where available while in-process access remains protected by a Go mutex.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, operating-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100