-
Notifications
You must be signed in to change notification settings - Fork 11
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
Dangerous race condition? #166
Comments
Thanks for the detailed report. I appreciate the concern, but I don't know that there is a solution to this outside of implementing cache functionality directly in If it's any reassurance, I've not seen the concurrency bug cause a problem for the entire time I've used the tool. BUT if it remains a concern, the CI script should mitigate it with additional measures for example by refusing to upload the cache if it has been updated since the last restore. The coarse grain lock would add protection at the cost of more pessimistic builds. |
Thank you for your response. It is good to hear that any potential issues are rare and possibly non-existent in the real world. My motivation for opening this issue is that the interaction between the components involved in this tool is complex. I may be misunderstanding something or my analysis may be wrong. Therefore I opened this issue in the interest of hearing from others whether or not my analysis is correct, and whether or not there is indeed a possibility for a (rare/theoretical) race condition that can cause corrupt builds and/or other bad stuff. |
Yes, I appreciate you raising the issue. This is worth documenting in the README in the least. For users who use this on Github, I think a Github Action can provide course level concurrency protection by default. |
For those who want to ensure 100% safety please be aware that a lock will provide additional safety but not 100%. One additional issue (I believe) is with the way the I think fixing this issue is actually fairly easy and worth doing in the code here. The fix is to upload the packages to S3 ordered by their dependency topology (carefully accounting for concurrent uploads). |
Good idea! Thanks! |
I had an idea on how to solve this. Store files into S3 as content addressed objects. Track the objects and their filenames in |
I was reading the internal concurrency guidelines of cabal install located here:
https://github.com/haskell/cabal/blob/df6de322c5f36dae48282ebae55985935eaced37/cabal-install/src/Distribution/Client/Store.hs#L53
This paragraph in particular looks very important, regarding multiple concurrent builds of the same package:
The regular
cabal-install
uses locking in order to protect against concurrent builds, butcabal-cache
does not do any locking.Therefore (if I am not mistaken) there is a danger that we can violate the above rule and get corrupt builds.
Here is an example scenario:
The text was updated successfully, but these errors were encountered: