Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

5.2.2
- Fixed the Redis Cluster backend failing with a syntax error on PHP 7.2 and 7.3
- Fixed the Redis Cluster backend failing with a fatal error when the numbers of configured hosts and ports do not match

5.2.1 - 2026-10-20
- Fixed queue processing failing with a fatal error, and some hits being counted twice, after a database deadlock or a MariaDB snapshot isolation conflict; requests hit by a snapshot isolation conflict are now retried
- Fixed requests being lost when the retry after a database deadlock or snapshot isolation conflict failed because of a different request
Expand Down
8 changes: 6 additions & 2 deletions Queue/Backend/RedisCluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
namespace Piwik\Plugins\QueuedTracking\Queue\Backend;

use Piwik\Log;
use Piwik\Piwik;
use Exception;

class RedisCluster extends Redis
{
Expand Down Expand Up @@ -305,13 +307,15 @@ protected function connect()
throw new Exception(Piwik::translate('QueuedTracking_NumHostsNotMatchNumPorts'));
}

$hostsPorts = array_map(fn($host, $port): string => "$host:$port", $hosts, $ports);
$hostsPorts = array_map(function ($host, $port): string {
return "$host:$port";
}, $hosts, $ports);

try {
$this->redis = new \RedisCluster(null, $hostsPorts, $this->timeout, $this->timeout, true, $this->password);
return true;
} catch (Exception $e) {
throw new Exception('Could not connect to redis cluster: ' . $e->getMessage());
throw new Exception('Could not connect to redis cluster: ' . $e->getMessage(), 0, $e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "QueuedTracking",
"version": "5.2.1",
"version": "5.2.2",
"description": "Scale your large traffic Matomo service by queuing tracking requests in Redis or MySQL for better performance and reliability when experiencing peaks.",
"theme": false,
"keywords": ["tracker", "tracking", "queue", "redis"],
Expand Down
19 changes: 19 additions & 0 deletions tests/Integration/Queue/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Piwik\Plugins\QueuedTracking\tests\Integration\Queue;

use Piwik\Config;
use Piwik\Piwik;
use Piwik\Plugins\QueuedTracking\Queue;
use Piwik\Plugins\QueuedTracking\Queue\Factory;
use Piwik\Plugins\QueuedTracking\SystemSettings;
Expand Down Expand Up @@ -75,6 +76,24 @@ public function test_makeBackend_shouldReturnASentinelInstanceIfConfigured()
$this->assertTrue($backend instanceof Queue\Backend\Sentinel);
}

public function testMakeBackendShouldReturnARedisClusterInstanceIfConfigured()
{
Config::getInstance()->QueuedTracking = ['useWhatRedisBackendType' => '3'];
$backend = Factory::makeBackend();
Config::getInstance()->QueuedTracking = [];
$this->assertTrue($backend instanceof Queue\Backend\RedisCluster);
}

public function testRedisClusterShouldExplainAHostAndPortMismatch()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage(Piwik::translate('QueuedTracking_NumHostsNotMatchNumPorts'));

$backend = new Queue\Backend\RedisCluster();
$backend->setConfig('127.0.0.1,127.0.0.2', '6379', 0.0, null);
$backend->getServerVersion();
}

public function test_makeBackend_shouldConfigureRedis()
{
$success = Factory::makeBackend()->testConnection();
Expand Down
Loading