-
-
Couldn't load subscription status.
- Fork 2.8k
Make sure core:archive terminates when all initial websites have been processed #12716
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note this does not 100% fix it. For example, say there are 50 sites in the initial list that are left to be archived. Now there are 2 archivers activate at the same time and each archive 25 sites. This means
$numWebsitesArchived = 25,$numWebsitesScheduled = 50and even though thesharedArchiveSiteIdhas been finished and will be reseted, we will still run for 25 more sites than it should be. Not sure how to avoid this. Was thinking of setting$numWebsitesScheduled = min($numWebsitesScheduled, count($this->websites-> getAllSiteIdsToArchive()))but then we would stop processing too early.I suppose what would help is like:
that way, if the number of remaining sites was reduced and not reseted, it may "auto correct itself but not 100% if that works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about this, and I'm not sure it works... If more sites get added to the queue, then
$numWebsitesScheduled = $numWebsitesLeft;might make it process more sites, right? Eg, if it's like in your example w/ two processing 50 sites, and when both are at 3 left, 25 more get added, the numWebsitesLeft will become 28 instead of 25. But it'll start to go down on the next iteration I guess. Hmm. I don't know if this will work or if it will fail :)Oh, here's another idea that may or may not work, what if there was a special 'null' entry in queue that would signal that this batch was done and this core:archive should stop? I guess that would also stop all future jobs too...
Or, for yet another random idea, what if the SharedSiteIds option had the current hour in the option name, so the once the core:archive instances finish that specific queue, they quit? I guess if one job ran for 5 hours because of an idsite in that queue, the rest of those sites would end up waiting. Maybe if a core:archive finishes one queue, but there are still queues for previous hours, they can start working on those. Eventually those processes will stop.
Idk, just throwing out ideas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah shouldn't because it would be only updated when there are less sites left unless I don't see it right.
yep exactly.
that's not quite working either because you might not run an archive command only once per hour but even more often. And sometimes the first sites take very long in which we need to make sure another job an hour later starts working on the next idsite.
This here is currently not a huge problem and we wouldn't even need to add another fix to it at all. But be good to let
core:archivetasks finish rather sooner than later.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be updated when there are less than the original (ie, 50), but not less than the current remaining jobs at the end (ie, 25). although it happens on every iteration, right? that could get weird if jobs keep getting added... I don't think I can predict what would happen then :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi @mattab @diosmosis I added another patch to this PR to detect this, and I implemented the patch in
SharedSiteIdsto on top detect when the shared site IDs have been processed.