Skip to content
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

More rigorous checks for non-existant site so archiving wont fail if … #16837

Merged
merged 4 commits into from Dec 2, 2020

Conversation

diosmosis
Copy link
Member

…a site is deleted + tweaks to some debug logs

Description:

Deleted some sites while a canceled/failed archive had been run before, and the next core:archive run would keep failing since the sites in the list didn't exist. Added some more checks for whether the site exists or not and fixed the existing check method.

FYI @tsteur

Review

  • Functional review done
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

…a site is deleted + tweaks to some debug logs
@diosmosis diosmosis added the Needs Review PRs that need a code review label Nov 30, 2020
@diosmosis diosmosis added this to the 4.0.3 milestone Nov 30, 2020
Comment on lines 414 to 419
try {
$this->assertEquals($expectedInvalidationsFound, $iteratedInvalidations);
} catch (\Exception $ex) {
print "\nInvalidations inserted:\n" . var_export($invalidations, true) . "\n";
throw $ex;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should assertEquals throw an exception? Shouldn't that be more like

Suggested change
try {
$this->assertEquals($expectedInvalidationsFound, $iteratedInvalidations);
} catch (\Exception $ex) {
print "\nInvalidations inserted:\n" . var_export($invalidations, true) . "\n";
throw $ex;
}
$this->assertEquals($expectedInvalidationsFound, $iteratedInvalidations, "Invalidations inserted:\n" . var_export($invalidations, true));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as the message (which will be very long) is readable and only displayed on failure, that would work too.

}

foreach ($next as &$item) {
Db::query("UPDATE " . Common::prefixTable('archive_invalidations') . " SET status = 1 WHERE idinvalidation = ?", [$item['idinvalidation']]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what that update is good for. Is it so getNextArchivesToProcess would not end up in a loop if any record is returned? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QueueConsumer only iterates through invalidations, it does not start archives, CronArchive does this as it launches new processes. This is to simulate this for the test, since QueueConsumer is only part of the whole loop.


private function getInvalidationCount()
{
return Db::fetchOne("SELECT COUNT(*) FROM " . Common::prefixTable('archive_invalidations'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That method actually isn't used anywhere 🤔

private function siteExists($idSite)
{
try {
$site = APISitesManager::getInstance()->getSiteFromId($idSite);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw could use new Site($idSite) here directly as it would use cache but maybe that be actually the problem and we don't want to hit the cache.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually be great if this hit the cache maybe? or would it cause a problem if the site was suddenly removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache would exist for the entire core:archive run, so a site could be removed say 30 mins after archiving starts, but it's data could still be cached, and we'd try to process it. We could maybe clear the cache before starting a new site archive so it's cached a bit... I'll think about it.

@tsteur
Copy link
Member

tsteur commented Nov 30, 2020

Looks generally good once tests pass @diosmosis 👍 there are a few comments to look at and a merge conflict but nothing major.

@diosmosis
Copy link
Member Author

@tsteur @sgiehl found a simpler solution that will avoid extra queries

@tsteur tsteur merged commit 72dabb6 into 4.x-dev Dec 2, 2020
@tsteur tsteur deleted the archiving-check-site-exists branch December 2, 2020 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants