Skip to content

Commit

Permalink
Start storing the processing host and process id for started invalida…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
sgiehl committed Jan 24, 2025
1 parent 0e6d346 commit 64caadf
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
8 changes: 6 additions & 2 deletions core/DataAccess/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,10 @@ public function startArchive($invalidation)
$table = Common::prefixTable('archive_invalidations');

// set archive value to in progress if not set already
$statement = Db::query("UPDATE `$table` SET `status` = ?, ts_started = NOW() WHERE idinvalidation = ? AND status = ?", [
$statement = Db::query("UPDATE `$table` SET `status` = ?, processing_host = ?, process_id = ?, ts_started = NOW() WHERE idinvalidation = ? AND status = ?", [
ArchiveInvalidator::INVALIDATION_STATUS_IN_PROGRESS,
gethostname() ?: null,
Common::getProcessId(),
$invalidation['idinvalidation'],
ArchiveInvalidator::INVALIDATION_STATUS_QUEUED,
]);
Expand All @@ -734,8 +736,10 @@ public function startArchive($invalidation)
}

// archive was started over 24 hours ago, we assume it failed and take it over
Db::query("UPDATE `$table` SET `status` = ?, ts_started = NOW() WHERE idinvalidation = ?", [
Db::query("UPDATE `$table` SET `status` = ?, processing_host = ?, process_id = ?, ts_started = NOW() WHERE idinvalidation = ?", [
ArchiveInvalidator::INVALIDATION_STATUS_IN_PROGRESS,
gethostname() ?: null,
Common::getProcessId(),
$invalidation['idinvalidation'],
]);

Expand Down
42 changes: 42 additions & 0 deletions core/Updates/5.3.0-b1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Updates;

use Piwik\Updater;
use Piwik\Updater\Migration\Factory as MigrationFactory;
use Piwik\Updates;

class Updates_5_3_0_b1 extends Updates
{
/**
* @var MigrationFactory
*/
private $migration;

public function __construct(MigrationFactory $factory)
{
$this->migration = $factory;
}

public function getMigrations(Updater $updater)
{
return [
$this->migration->db->addColumns('archive_invalidations', [
'processing_host' => 'VARCHAR(100) NULL DEFAULT NULL',
'process_id' => 'VARCHAR(15) NULL DEFAULT NULL'
])
];
}

public function doUpdate(Updater $updater)
{
$updater->executeMigrations(__FILE__, $this->getMigrations($updater));
}
}
2 changes: 1 addition & 1 deletion core/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class Version
* The current Matomo version.
* @var string
*/
public const VERSION = '5.3.0-alpha';
public const VERSION = '5.3.0-b1';

public const MAJOR_VERSION = 5;

Expand Down

0 comments on commit 64caadf

Please sign in to comment.