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
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2019-08-30 01:18:47 +0300
committerGitHub <noreply@github.com>2019-08-30 01:18:47 +0300
commitea8a3063d97a71c5be0357a64eb29343b4c97385 (patch)
tree62c08d4d217fadc25d23eb3cb0f851149b228a32
parentad12a4ff5e711560124e086d80526ad43af24ce6 (diff)
Update archive status instead of delete and insert (#14816)
* update archive status instead of delete and insert * remove no longer needed locks * better query
-rw-r--r--core/DataAccess/ArchiveWriter.php11
-rw-r--r--core/DataAccess/Model.php31
2 files changed, 4 insertions, 38 deletions
diff --git a/core/DataAccess/ArchiveWriter.php b/core/DataAccess/ArchiveWriter.php
index 82f9f96d7e..9d729c6c4a 100644
--- a/core/DataAccess/ArchiveWriter.php
+++ b/core/DataAccess/ArchiveWriter.php
@@ -140,9 +140,7 @@ class ArchiveWriter
$numericTable = $this->getTableNumeric();
$idArchive = $this->getIdArchive();
- $this->getModel()->deletePreviousArchiveStatus($numericTable, $idArchive, $this->doneFlag);
-
- $this->logArchiveStatusAsFinal();
+ $this->getModel()->updateArchiveStatus($numericTable, $idArchive, $this->doneFlag, self::DONE_OK);
}
protected function compress($data)
@@ -172,13 +170,6 @@ class ArchiveWriter
$this->insertRecord($this->doneFlag, self::DONE_ERROR);
}
- protected function logArchiveStatusAsFinal()
- {
- $status = self::DONE_OK;
-
- $this->insertRecord($this->doneFlag, $status);
- }
-
protected function insertBulkRecords($records)
{
// Using standard plain INSERT if there is only one record to insert
diff --git a/core/DataAccess/Model.php b/core/DataAccess/Model.php
index 1fd4455833..8b29041f6d 100644
--- a/core/DataAccess/Model.php
+++ b/core/DataAccess/Model.php
@@ -272,25 +272,11 @@ class Model
return $idarchive;
}
- public function deletePreviousArchiveStatus($numericTable, $archiveId, $doneFlag)
+ public function updateArchiveStatus($numericTable, $archiveId, $doneFlag, $value)
{
- $tableWithoutLeadingPrefix = $numericTable;
- $lenNumericTableWithoutPrefix = strlen('archive_numeric_MM_YYYY');
-
- if (strlen($numericTable) >= $lenNumericTableWithoutPrefix) {
- $tableWithoutLeadingPrefix = substr($numericTable, strlen($numericTable) - $lenNumericTableWithoutPrefix);
- // we need to make sure lock name is less than 64 characters see https://github.com/piwik/piwik/issues/9131
- }
- $dbLockName = "rmPrevArchiveStatus.$tableWithoutLeadingPrefix.$archiveId";
-
- // without advisory lock here, the DELETE would acquire Exclusive Lock
- $this->acquireArchiveTableLock($dbLockName);
-
- Db::query("DELETE FROM $numericTable WHERE idarchive = ? AND (name = '" . $doneFlag . "')",
- array($archiveId)
+ Db::query("UPDATE $numericTable SET `value` = ? WHERE idarchive = ? and `name` = ?",
+ array($value, $archiveId, $doneFlag)
);
-
- $this->releaseArchiveTableLock($dbLockName);
}
public function insertRecord($tableName, $fields, $record, $name, $value)
@@ -407,15 +393,4 @@ class Model
return "((name IN ($allDoneFlags)) AND (value IN (" . implode(',', $possibleValues) . ")))";
}
- protected function acquireArchiveTableLock($dbLockName)
- {
- if (Db::getDbLock($dbLockName, $maxRetries = 30) === false) {
- throw new Exception("Cannot get named lock $dbLockName.");
- }
- }
-
- protected function releaseArchiveTableLock($dbLockName)
- {
- Db::releaseDbLock($dbLockName);
- }
}