-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
clarification on the safety requirement for the Locker interface #196
Comments
This is potentially related to #58 |
An improper implementation may cause ACME challenges to fail because two instances are presenting different credentials for the same domain at the same time. Or two instances will successfully fail to share or coordinate the certificate they obtained, resulting in rate limit overages. It's also using for distributed STEK coordination, so if locking is not properly implemented, clients' TLS sessions will end and performance will decrease. The underlying storage mechanism must support atomic operations (for example, S3 does not). Does that help? |
I understand that Let me just give an example for better explaining. Suppose that the KV (https://developers.cloudflare.com/workers/learning/how-kv-works/):
However,
Durable Objects (https://developers.cloudflare.com/workers/learning/using-durable-objects/): What is not clear to me is that,
You can imagine the situation where one would implement the |
Ah I see, good questions.
If I understand you right, it sounds like you are asking about Lock/Unlock being used to guard or synchronize Load/Store/etc. Load/Store/etc should be blocking and synchronous on their own; meaning that when Based on what you described about Cloudflare KV, it sounds like this would require waiting for propagation or something like that, before returning from an implementation of Lock and Unlock, though, are a little different. Think of them just like
So yes, callers should be able to immediately read their writes. Lock/Unlock are not expected to be used around synchronous calls to Load/Store. The caller doesn't know or care whether the underlying storage system is synchronous or asynchronous. If it's asynchronous, the Storage implementation should take care of that so it acts synchronous. I'll try to clarify this in the godocs. |
Thank you, just gotta make sure about the requirement of the related: https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html |
Can we assume that if CertMagic calls You can imagine that once it calls |
No; locks are basically named mutexes, they have nothing to do with individual files/keys. Usually a lock name represents a specific/unique operation or job that is being performed. The storage implementation should do its own sync for file reads/writes. For example, it should block calls to
Think of (I pushed a commit below that clarifies the docs, hopefully that is better. Feel free to continue with discussion or ask more questions if needed.) |
What is your question?
re: https://github.com/caddyserver/certmagic/blob/master/storage.go#L75
How is the
Lock
used for the purpose of certmagic? Is it used to save on redundant work (e.g. it is ok to try to renew a certificate a second time), or to guarantee correctness (e.g. absolutely no one else is able to update the certificate other than me otherwise the world catches on fire).While the comment hints to me that it is the former, it is not at all clear to me that if certmagic relies on the correctness of the locking property.
For context, I'm trying to integrate certmagic in a personal project with an abstract KV interface. While the rest of the
Storage
interface is straightforward, I'm unsure about the guarantee thatLocker
provides (hence, expectations of the underlying implementation).The text was updated successfully, but these errors were encountered: