-
Notifications
You must be signed in to change notification settings - Fork 103
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
Add Lock Support #186
Comments
Hello, Thank you for reporting this issue. I usually rely on a system based lock which I write in my crontabs, something like :
Adding a lock support could be possible, but I dislike adding optional dependencies : it's always painful to maintain. Do you think that |
@yann-eugone Hi! Thank you for the response! The The whole process of generation in this bundle, as far as I can see, is atomic and indeed multiple sections can be generated at the same time... almost :) I agree on maintenance of the additional dependency. If so I was thinking about adding |
You want to use the a section based lock to protect the Improving performance is always a good thing. About the "optional dependency" thing. |
I poked around and you're right about the suggest problem, but I think the solution is simple. The default dumper does a parallel-sensitive operations within these lines: PrestaSitemapBundle/Service/Dumper.php Lines 98 to 118 in 5c9f41e
The lock should be acquired before, since collection & saving of XMLs can happen in the same time. The only sensitive operation is actually updating the index. Doing such detection sort of off-line during build allows for a great DX - you may get a warning during container compilation (from container extension) saying "hey, if you install Lock we will give you parallel compatibility, otherwise don't run two generations at the same time". As an improvement (which I think is out of scope for this issue) we may use a simple Of course the solution is not idiot-proof: you can still run the same section twice, or run a section + all sections at the same time and break the sitemap potentially. WDYT? |
Currently nothing prevents
usercrontab from running two copies ofpresta:sitemaps:dump
twice. This will cause race condition for index modification.I think support for blocking FS-based lock type can be easily added using Symfony Lock, so that still you can generate multiple roots at once but the index operations are locked to only one instance at any given time.
WDYT?
The text was updated successfully, but these errors were encountered: