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:
authorThomas Steur <tsteur@users.noreply.github.com>2022-04-01 10:35:13 +0300
committerGitHub <noreply@github.com>2022-04-01 10:35:13 +0300
commit06981c78f207ca11c25502205d8879ea08863529 (patch)
treec8fc1f01c1ee380b168850865ad4630a156db66d /core
parent19489d103c6b4e91a745492e7ccffd957c3dcb4f (diff)
Clear general cache less often when launching the archiving (#19000)
* Clear general cache less often when launching the archiving * invalidate only when needed * optimise clear general cache * better naming * try better approach * simplify * simplify further
Diffstat (limited to 'core')
-rw-r--r--core/Archive/ArchiveInvalidator.php31
1 files changed, 24 insertions, 7 deletions
diff --git a/core/Archive/ArchiveInvalidator.php b/core/Archive/ArchiveInvalidator.php
index b05412c95f..585c22dd8a 100644
--- a/core/Archive/ArchiveInvalidator.php
+++ b/core/Archive/ArchiveInvalidator.php
@@ -205,8 +205,10 @@ class ArchiveInvalidator
public function forgetRememberedArchivedReportsToInvalidateForSite($idSite)
{
$id = $this->buildRememberArchivedReportIdForSite($idSite) . '_';
- $this->deleteOptionLike($id);
- Cache::clearCacheGeneral();
+ $hasDeletedSomething = $this->deleteOptionLike($id);
+ if ($hasDeletedSomething) {
+ Cache::clearCacheGeneral();
+ }
}
/**
@@ -220,9 +222,14 @@ class ArchiveInvalidator
// The process pid is added to the end of the entry in order to support multiple concurrent transactions.
// So this must be a deleteLike call to get all the entries, where there used to only be one.
- $this->deleteOptionLike($id);
+ return $this->deleteOptionLike($id);
}
+ /**
+ * @param $id
+ * @return bool true if a record was deleted, false otherwise.
+ * @throws \Zend_Db_Statement_Exception
+ */
private function deleteOptionLike($id)
{
// we're not using deleteLike since it maybe could cause deadlocks see https://github.com/matomo-org/matomo/issues/15545
@@ -230,7 +237,7 @@ class ArchiveInvalidator
$keys = Option::getLike('%' . str_replace('_', '\_', $id) . '%');
if (empty($keys)) {
- return;
+ return false;
}
$keys = array_keys($keys);
@@ -238,7 +245,8 @@ class ArchiveInvalidator
$placeholders = Common::getSqlStringFieldsArray($keys);
$table = Common::prefixTable('option');
- Db::query('DELETE FROM `' . $table . '` WHERE `option_name` IN (' . $placeholders . ')', $keys);
+ $db = Db::query('DELETE FROM `' . $table . '` WHERE `option_name` IN (' . $placeholders . ')', $keys);
+ return (bool) $db->rowCount();
}
/**
@@ -250,6 +258,7 @@ class ArchiveInvalidator
* @param bool $forceInvalidateNonexistantRanges set true to force inserting rows for ranges in archive_invalidations
* @param string $name null to make sure every plugin is archived when this invalidation is processed by core:archive,
* or a plugin name to only archive the specific plugin.
+ * @param bool $ignorePurgeLogDataDate
* @return InvalidationResult
* @throws \Exception
*/
@@ -280,6 +289,7 @@ class ArchiveInvalidator
&& count($dates) == 1
&& ((string)$dates[0]) == ((string)Date::factoryInTimezone('today', $tz))
) {
+ // date is for today
$hasMoreThanJustToday[$idSite] = false;
}
}
@@ -315,20 +325,27 @@ class ArchiveInvalidator
$isInvalidatingDays = $period == 'day' || $cascadeDown || empty($period);
$isNotInvalidatingSegment = empty($segment) || empty($segment->getString());
+
if ($isInvalidatingDays
&& $isNotInvalidatingSegment
) {
+
+ $hasDeletedAny = false;
+
foreach ($idSites as $idSite) {
foreach ($dates as $date) {
if (is_string($date)) {
$date = Date::factory($date);
}
- $this->forgetRememberedArchivedReportsToInvalidate($idSite, $date);
+ $hasDeletedAny = $this->forgetRememberedArchivedReportsToInvalidate($idSite, $date) || $hasDeletedAny;
}
}
+
+ if ($hasDeletedAny) {
+ Cache::clearCacheGeneral();
+ }
}
- Cache::clearCacheGeneral();
return $invalidationInfo;
}