diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2020-11-26 09:26:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-26 09:26:55 +0300 |
commit | be3488e23d8b35452210db387e8ab39059d27da2 (patch) | |
tree | 0ae9795e4275bc12be8ca47fb2bf6492ccf55e21 /core | |
parent | c3cb22117048ac18c8973af3da32f9697597c24b (diff) |
Invalidate everything once before a site is archived and do not inval… (#16796)
* Invalidate everything once before a site is archived and do not invalidate again until a core:archive run sees that site.
* remove no longer needed code
* do not invalidate if there is already an invalidation for the site from today
* remove ts_invalidated check + another query tweak
* fix test
* fix another test
Diffstat (limited to 'core')
-rw-r--r-- | core/CronArchive/QueueConsumer.php | 10 | ||||
-rw-r--r-- | core/DataAccess/Model.php | 21 |
2 files changed, 17 insertions, 14 deletions
diff --git a/core/CronArchive/QueueConsumer.php b/core/CronArchive/QueueConsumer.php index c433e5b927..c702423166 100644 --- a/core/CronArchive/QueueConsumer.php +++ b/core/CronArchive/QueueConsumer.php @@ -151,12 +151,12 @@ class QueueConsumer $this->siteTimer = new Timer(); $this->siteRequests = 0; - } - // check if we need to process invalidations - // NOTE: we do this on every iteration so we don't end up processing say a single user entered invalidation, - // and then stop until the next hour. - $this->cronArchive->invalidateArchivedReportsForSitesThatNeedToBeArchivedAgain($this->idSite); + // check if we need to process invalidations + // NOTE: we do this on every site iteration so we don't end up processing say a single user entered invalidation, + // and then stop until the next hour. + $this->cronArchive->invalidateArchivedReportsForSitesThatNeedToBeArchivedAgain($this->idSite); + } // we don't want to invalidate different periods together or segment archives w/ no-segment archives // together, but it's possible to end up querying these archives. if we find one, we keep track of it diff --git a/core/DataAccess/Model.php b/core/DataAccess/Model.php index 0742709197..6007994623 100644 --- a/core/DataAccess/Model.php +++ b/core/DataAccess/Model.php @@ -696,7 +696,7 @@ class Model $bind[] = $invalidation['report']; } - $sql = "SELECT idinvalidation FROM `$table` WHERE idsite = ? AND `period` = ? AND date1 = ? AND date2 = ? AND `name` = ? AND `status` = ? AND $reportClause LIMIT 1"; + $sql = "SELECT idinvalidation FROM `$table` WHERE idsite = ? AND `period` = ? AND date1 = ? AND date2 = ? AND `name` = ? AND `status` = ? AND ts_started IS NOT NULL AND $reportClause LIMIT 1"; $result = Db::fetchOne($sql, $bind); return !empty($result); @@ -840,14 +840,6 @@ class Model Db::query($sql); } - public function isInvalidationsScheduledForSite($idSite) - { - $table = Common::prefixTable('archive_invalidations'); - $sql = "SELECT idsite FROM `$table` WHERE idsite = ? LIMIT 1"; - $value = Db::fetchOne($sql, [(int) $idSite]); - return !empty($value); - } - private function getRemoveInvalidationsIdSitesClause($idSite) { if ($idSite === 'all') { @@ -882,4 +874,15 @@ class Model $query = Db::query($sql, $bind); return $query->rowCount(); } + + public function isInvalidationsScheduledForSite($idSite) + { + $table = Common::prefixTable('archive_invalidations'); + + $bind = [(int) $idSite]; + + $sql = "SELECT idsite FROM `$table` WHERE idsite = ? LIMIT 1"; + $value = Db::fetchOne($sql, $bind); + return !empty($value); + } } |