Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authordiosmosis <diosmosis@users.noreply.github.com>2020-12-02 05:55:12 +0300
committerGitHub <noreply@github.com>2020-12-02 05:55:12 +0300
commit72dabb63267d431075169f6ada8c72bfd329e6e8 (patch)
tree33cb3e18100a3135c75fc993a2f4659eaa4bd4eb /core
parentf4dd5624a1f56602ea449668a40e00b70f0e28f4 (diff)
More rigorous checks for non-existant site so archiving wont fail if … (#16837)
Diffstat (limited to 'core')
-rw-r--r--core/Archive/ArchivePurger.php8
-rw-r--r--core/CronArchive.php26
-rw-r--r--core/CronArchive/QueueConsumer.php20
3 files changed, 34 insertions, 20 deletions
diff --git a/core/Archive/ArchivePurger.php b/core/Archive/ArchivePurger.php
index 09621dabce..59fc2c51f2 100644
--- a/core/Archive/ArchivePurger.php
+++ b/core/Archive/ArchivePurger.php
@@ -139,10 +139,10 @@ class ArchivePurger
$this->logger->debug("No outdated archives found in archive numeric table for {date}.", array('date' => $dateStart));
}
- $this->logger->debug("Purging temporary archives: done [ purged archives older than {date} in {yearMonth} ] [Deleted IDs: {deletedIds}]", array(
+ $this->logger->debug("Purging temporary archives: done [ purged archives older than {date} in {yearMonth} ] [Deleted IDs count: {deletedIds}]", array(
'date' => $purgeArchivesOlderThan,
'yearMonth' => $dateStart->toString('Y-m'),
- 'deletedIds' => implode(',', $idArchivesToDelete)
+ 'deletedIds' => count($idArchivesToDelete),
));
return $deletedRowCount;
@@ -191,8 +191,8 @@ class ArchivePurger
)
);
- $this->logger->debug("[Deleted IDs: {deletedIds}]", array(
- 'deletedIds' => implode(',', $idArchivesToDelete)
+ $this->logger->debug("[Deleted IDs count: {deletedIds}]", array(
+ 'deletedIds' => count($idArchivesToDelete),
));
} else {
$this->logger->debug(
diff --git a/core/CronArchive.php b/core/CronArchive.php
index a2335520fb..2903290884 100644
--- a/core/CronArchive.php
+++ b/core/CronArchive.php
@@ -26,6 +26,7 @@ use Piwik\DataAccess\ArchiveSelector;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\DataAccess\Model;
use Piwik\DataAccess\RawLogDao;
+use Piwik\Exception\UnexpectedWebsiteFoundException;
use Piwik\Metrics\Formatter;
use Piwik\Period\Factory;
use Piwik\Period\Factory as PeriodFactory;
@@ -361,7 +362,14 @@ class CronArchive
flush();
}
- $archivesToProcess = $queueConsumer->getNextArchivesToProcess();
+ try {
+ $archivesToProcess = $queueConsumer->getNextArchivesToProcess();
+ } catch (UnexpectedWebsiteFoundException $ex) {
+ $this->logger->debug("Site {$queueConsumer->getIdSite()} was deleted, skipping to next...");
+ $queueConsumer->skipToNextSite();
+ continue;
+ }
+
if ($archivesToProcess === null) {
break;
}
@@ -406,6 +414,12 @@ class CronArchive
}
$idSite = $archive['idsite'];
+ if (!$this->siteExists($idSite)) {
+ $this->logger->debug("Site $idSite no longer exists, no longer launching archiving.");
+ $this->deleteInvalidatedArchives($archive);
+ continue;
+ }
+
$dateStr = $archive['period'] == Range::PERIOD_ID ? ($archive['date1'] . ',' . $archive['date2']) : $archive['date1'];
$period = PeriodFactory::build($this->periodIdsToLabels[$archive['period']], $dateStr);
$params = new Parameters(new Site($idSite), $period, new Segment($segment, [$idSite], $period->getDateStart(), $period->getDateEnd()));
@@ -1252,4 +1266,14 @@ class CronArchive
]);
}
}
+
+ private function siteExists($idSite)
+ {
+ try {
+ new Site($idSite);
+ return true;
+ } catch (\UnexpectedValueException $ex) {
+ return false;
+ }
+ }
}
diff --git a/core/CronArchive/QueueConsumer.php b/core/CronArchive/QueueConsumer.php
index c702423166..9dd07e4ba3 100644
--- a/core/CronArchive/QueueConsumer.php
+++ b/core/CronArchive/QueueConsumer.php
@@ -18,6 +18,7 @@ use Piwik\CronArchive;
use Piwik\DataAccess\ArchiveSelector;
use Piwik\DataAccess\Model;
use Piwik\Date;
+use Piwik\Exception\UnexpectedWebsiteFoundException;
use Piwik\Period;
use Piwik\Period\Factory as PeriodFactory;
use Piwik\Piwik;
@@ -123,12 +124,6 @@ class QueueConsumer
public function getNextArchivesToProcess()
{
- // in case a site is deleted while archiving is running
- if (!empty($this->idSite) && !$this->isSiteExists($this->idSite)) {
- $this->logger->debug("Site ID = {$this->idSite} was deleted during archiving process, moving on.");
- $this->idSite = null;
- }
-
if (empty($this->idSite)) {
$this->idSite = $this->getNextIdSiteToArchive();
if (empty($this->idSite)) { // no sites left to archive, stop
@@ -490,13 +485,9 @@ class QueueConsumer
$this->invalidationsToExclude[$idinvalidation] = $idinvalidation;
}
- private function getDoneFlagType($name)
+ public function skipToNextSite()
{
- if ($name == 'done') {
- return 'all';
- } else {
- return 'segment';
- }
+ $this->idSite = null;
}
private function addInvalidationToExclude(array $invalidatedArchive)
@@ -556,9 +547,8 @@ class QueueConsumer
return Date::factory($archiveIdAndVisits[4])->getDatetime();
}
- private function isSiteExists($idSite)
+ public function getIdSite()
{
- $site = API::getInstance()->getSiteFromId($idSite);
- return !empty($site);
+ return $this->idSite;
}
} \ No newline at end of file