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
Fixes for specific case when partial archives have to initiate archiving for child archives #17439
Conversation
…hecks for partial archives, fix a couple issues that arise when archiving a multi-period partial archive that has to initiate archiving for a child archive and reuse archives for a child archive.
core/ArchiveProcessor/Loader.php
Outdated
@@ -105,6 +105,7 @@ public function prepareArchive($pluginName) | |||
private function prepareArchiveImpl($pluginName) | |||
{ | |||
$this->params->setRequestedPlugin($pluginName); | |||
$this->params->setIsPartialArchive(false); |
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.
Normally when configuring Params objects, we create new ones where partial archive is set to false
to begin with. Here in Loader, however, we reuse Params objects to archive VisitsSummary by itself, and then the rest of the plugins. When reusing, we have to specifically reset this property, or other archives will think they are partial archives.
This is the only place this should be done, so I did not consider changing Params a good idea, since developers should only use the setIsPartialArchive
method in Archiver instances for a specific use case.
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.
@diosmosis in line 113 should it set $this->params->setArchiveOnlyReport($requestedReport)
or maybe setArchiveOnlyReport()
should set setIsPartialArchive
automatically?
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.
do we ever need to reset the original/previously set IsPartialArchive
value maybe? haven't checked yet where it's reused
@@ -117,8 +118,7 @@ private function prepareArchiveImpl($pluginName) | |||
// with a ts_archived >= the DONE_OK/DONE_INVALIDATED date. | |||
list($idArchives, $visits, $visitsConverted, $isAnyArchiveExists) = $this->loadExistingArchiveIdFromDb(); | |||
if (!empty($idArchives) | |||
&& !$this->params->getArchiveOnlyReport() |
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.
Removed this since it seemed safer to reuse existing archives if we're not forcing single plugin archiving, and not depend on this state which comes from a query param.
$metrics = $pluginsArchiver->callAggregateCoreMetrics(); | ||
$pluginsArchiver->finalizeArchive(); | ||
return $metrics; | ||
}); |
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.
Unset requestedReport
so it's not picked up if we recurse here. If we're getting core metrics for a week, and there isn't a day archive already existing, we'll try to create the archive. But w/ requestedReport set, we may try to archive the other plugin as well as VisitsSummary. (Note: this can be seen in the new test if the code is removed.)
@@ -328,17 +328,20 @@ public static function getSelectableDoneFlagValues($includeInvalidated = true, P | |||
return $possibleValues; | |||
} | |||
|
|||
public static function isForceArchivingSinglePlugin() | |||
public static function isRequestingToAndAbleToForceArchiveSinglePlugin() |
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.
Renamed to show it's true function more clearly.
public static function isActuallyForceArchivingSinglePlugin() | ||
{ | ||
return Loader::getArchivingDepth() <= 1 && self::isRequestingToAndAbleToForceArchiveSinglePlugin(); | ||
} |
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.
We now have two methods to determine if we are forcing archiving of a single plugin:
- isRequestingToAndAbleToForceArchiveSinglePlugin() which returns true if the original request was for a pluginOnly archive, and if it came from archive.php (so we're able to in that case).
- and isActuallyForceArchivingSinglePlugin() which returns true if in this specific archiving request, we want to archive a pluginOnly archive. We only do this for the root request, for others we try to reuse existing archives. If no existing archives exist, archiving will launch for them so we don't need to do anything (unless, like in the Cloud plugin, we force disable it).
// sanity check: DONE_PARTIAL shouldn't be used w/ done archives, but in case we see one, | ||
// don't treat it like an all plugins archive | ||
&& $value != ArchiveWriter::DONE_PARTIAL | ||
) { |
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.
This and the above code is a safety check for if an archive has a done
like flag but DONE_PARTIAL
value. In case of problematic data like this, we just treat it like another partial archive.
'exception' => $ex, | ||
]); | ||
} | ||
} |
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.
Adding a log just in case there is some other way to create a partial archive w/o a plugin done flag.
FYI @tsteur |
@diosmosis can you have a look at the failing test they might be related to this? If they fail because of this PR I will have another look after fixing it |
@tsteur relevant tests should pass now |
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.
haven't tested anything but left few comments just to check. Looked through the code and wasn't sure if it could maybe result in some wrong archiving like when we mark something as not partial but we actually only want to archive a plugin.
core/ArchiveProcessor/Loader.php
Outdated
@@ -105,6 +105,7 @@ public function prepareArchive($pluginName) | |||
private function prepareArchiveImpl($pluginName) | |||
{ | |||
$this->params->setRequestedPlugin($pluginName); | |||
$this->params->setIsPartialArchive(false); |
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.
@diosmosis in line 113 should it set $this->params->setArchiveOnlyReport($requestedReport)
or maybe setArchiveOnlyReport()
should set setIsPartialArchive
automatically?
core/ArchiveProcessor/Loader.php
Outdated
@@ -105,6 +105,7 @@ public function prepareArchive($pluginName) | |||
private function prepareArchiveImpl($pluginName) | |||
{ | |||
$this->params->setRequestedPlugin($pluginName); | |||
$this->params->setIsPartialArchive(false); |
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.
do we ever need to reset the original/previously set IsPartialArchive
value maybe? haven't checked yet where it's reused
@@ -184,13 +184,18 @@ protected function prepareCoreMetricsArchive($visits, $visitsConverted) | |||
|
|||
$this->params->setRequestedPlugin('VisitsSummary'); | |||
$this->params->setArchiveOnlyReport(null); | |||
$this->params->setIsPartialArchive(false); |
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.
would we need to back up the previously set value and restore it below in line 198?
I don't think it's technically necessary to set it, but it makes sense to be thorough. I thought about unsetting it in that method, but we never re-use Parameters objects anywhere else (and shouldn't in normal uses), so it seemed like it could cause strange side effects.
In that specific line of code, no, because that's the start of the prepareArchive() method. In fact in that line of code we don't need to call the method there. I'll remove that.
Don't need to since we archive VisitsSummary before other plugins. We could do it, though, just in case something changes in the future. |
I reckon that might be useful just in case |
@tsteur applied pr feedback |
fyi @diosmosis there are now some merge conflicts from merging the other PR |
@tsteur 👍 just fixed, we'll see if the build passes |
btw is this one now no longer needed 706621b#diff-3ad7e38a2ff2d49f9ac9f268bf0ce70db9b1a924be38e5802816acc0ae343d32L108 ? |
@tsteur it was never really needed, since Loader is given a new Parameters instance just before using it. So it's already in a clean state. |
Description:
Refs #17428
Includes new test case and changes to make it pass. See inline comments for individual changes/fixes.
Review