matomo-org / plugin-QueuedTracking

Scale your large traffic Matomo service by queuing tracking requests (in Redis or MySQL) for better performance.
https://matomo.org
GNU General Public License v3.0
82 stars 35 forks source link

matomo.php returns HTTP 200 when unable to connect to redis #97

Open toredash opened 5 years ago

toredash commented 5 years ago

If matomo is configured to use QueuedTracking with Redis as backend, and matomo.php is unable to connect to such Redis instance, HTTP 200 is returned.

I would expect matomo.php return !200. For monitoring the availability of the tracker API, it makes it harder to validate that the Tracker API is healthy.

The error msg that is returned:


<br />
<b>Warning</b>:  Redis::connect(): connect() failed: Cannot assign requested address in <b>/var/www/html/vendor/piwik/cache/src/Backend/Factory.php</b> on line <b>60</b><br />
<br />
<b>Fatal error</b>:  Uncaught RedisException: Redis server went away in /var/www/html/vendor/piwik/cache/src/Backend/Factory.php:70
Stack trace:
#0 /var/www/html/vendor/piwik/cache/src/Backend/Factory.php(70): Redis-&gt;select(0)
#1 /var/www/html/vendor/piwik/cache/src/Backend/Factory.php(108): Piwik\Cache\Backend\Factory-&gt;buildRedisCache(Array)
#2 /var/www/html/core/Cache.php(75): Piwik\Cache\Backend\Factory-&gt;buildBackend('redis', Array)
#3 /var/www/html/config/global.php(67): Piwik\Cache::buildBackend('redis')
#4 [internal function]: DI\Definition\Source\DefinitionFile-&gt;{closure}(Object(DI\Container))
#5 /var/www/html/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#6 /var/www/html/vendor/php-di/php-di/src/DI/Definition/Resolver/FactoryResolver.php(81): Invoker\Invoker-&gt;call(Object(Closure), Array)
#7 /var/www/html/vendor/php-di/php-di/src/DI/Definition/Resolver/ResolverDispatcher.php(58): DI\Definition\Resolver\FactoryResolver-&gt;resolve(Object(DI\Definition\FactoryDefinition), Array)
#8 /var in <b>/var/www/html/vendor/piwik/cache/src/Backend/Factory.php</b> on line <b>70</b><br />```

Headers returned:
```Request URL: X/matomo.php
Request Method: GET
Status Code: 200 ```
tsteur commented 5 years ago

Would require a bit of work here: https://github.com/matomo-org/plugin-QueuedTracking/blob/3.3.5/Queue/Manager.php#L153 to count the number of errors across all requests (we wouldn't stop all requests but only throw an exception at the end of the method if any failed).

Would also need to return the success value here: https://github.com/matomo-org/plugin-QueuedTracking/blob/3.3.5/Queue.php#L75 and would also need to return success/failure status in the MySQL and Redis backend in the appendValuesToList() method.

It may not all be hard to develop but creating tests for all this is the time consuming part.