plugin-QueuedTracking icon indicating copy to clipboard operation
plugin-QueuedTracking copied to clipboard

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

Open toredash opened this issue 6 years ago • 1 comments

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 ```

toredash avatar Feb 13 '19 10:02 toredash

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.

tsteur avatar May 07 '19 20:05 tsteur