-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Queue is not processed #22
Comments
Hi @akrus can you try to disable Ldap plugin and see if this changes anything? |
Disabled, debug messages disappeared, but still no data is processed. |
@akrus sorry but we don't know what could cause this issue. Does anyone else experience this? |
Are you using any other non-standard plugins apart from Ldap? If so, can you maybe disable them and try again? Also can you check your server logs if there are any errors? Can you maybe have a look in the config ( |
We have the following extra plugins: Error logs are empty, I checked them already :) record_statistics is set to 1. I'll try disabling plugins later and let you know. |
OK please let me know. I was hoping it would be the |
Tried disabling plugins, nothing changed. installation_in_progress is not present and database credentials are configured. |
I wonder if it's maybe related with Redis 3.X. Can't think of anything else right now, it should work. By any chance can you try to use the latest Redis 2.X easily? |
I just updated from Redis 2.8 to latest 3.0.5 and it worked fine. Are you familiar with PHP programming language maybe? |
Or maybe you can provide us access to your server so we can debug? If so, feel free to send us credentials via email to hello at piwik.org |
I can switch to 2.x, should I? I'm familiar with php, but I'd need some assistance from your side to debug this :) unfortunately I cannot provide access there :( |
Here is basically where the magic happens: https://github.com/piwik/plugin-QueuedTracking/blob/master/Queue/Processor.php#L64-L110 What I thought in the first place, is that for some reason it seams to stop here: https://github.com/piwik/plugin-QueuedTracking/blob/master/Queue/Processor.php#L68-L69 Maybe you can just add some public function process(Tracker $tracker = null)
{
$tracker = $tracker ?: new Tracker();
var_dump('Process');
if (!$tracker->shouldRecordStatistics()) {
var_dump('ignore');
return $tracker;
}
$request = new RequestSet();
$request->rememberEnvironment();
$loops = 0;
try {
while ($queue = $this->queueManager->lockNext()) {
var_dump($loops);
if ($loops > $this->numMaxBatchesToProcess) {
Common::printDebug('This worker processed ' . $loops . ' times, stopping now.');
break;
} else {
$loops++;
}
$queuedRequestSets = $queue->getRequestSetsToProcess();
var_dump('Num Request Sets: ' . count($queuedRequestSets));
if (!empty($queuedRequestSets)) {
$requestSetsToRetry = $this->processRequestSets($tracker, $queuedRequestSets);
var_dump('Num Request Sets to retry because they failed: ' . count($requestSetsToRetry));
$this->processRequestSets($tracker, $requestSetsToRetry);
$queue->markRequestSetsAsProcessed();
}
$this->queueManager->unlock();
}
} catch (Exception $e) {
var_dump('Exception: ' . $e->getMessage());
Common::printDebug('Failed to process a request set: ' . $e->getMessage());
$this->queueManager->unlock();
$request->restoreEnvironment();
throw $e;
}
$request->restoreEnvironment();
var_dump('Process end');
exit;
return $tracker;
} |
Sorry for delay, was on holidays :) here is output: ./console queuedtracking:processStarting to process request sets, this can take a while |
Thanks for that. I have a suspect but let's see. Do you mind doing the same with another file? This time It would be the method public function lockNext()
{
var_dump('lockNext');
$this->unlock();
var_dump('CurrentQueueId: ' . $this->currentQueueId);
var_dump('Num RequestsToProcess: ' . $this->numRequestsToProcessInBulk);
var_dump('Num QueuesAvailable: ' . $this->numQueuesAvailable);
if ($this->currentQueueId < 0) {
// we just want to avoid to always start looking for the queue at position 0
$this->currentQueueId = rand(0, $this->numQueuesAvailable - 1);
}
var_dump('Actual CurrentQueueId: ' . $this->currentQueueId);
// here we look for all available queues whether at least one should and can be processed
$start = $this->currentQueueId + 1; // this way we make sure to rotate through all queues
$end = $start + $this->numQueuesAvailable;
var_dump(sprintf('Start:End %s: %s', $start, $end));
for (; $start < $end; $start++) {
$this->currentQueueId = $start % $this->numQueuesAvailable;
var_dump('--Testing queue ' . $this->currentQueueId);
$queue = $this->createQueue($this->currentQueueId);
var_dump('Num Requests To Process: ' . $queue->getNumberOfRequestSetsInQueue());
var_dump('getNumberOfRequestsToProcessAtSameTime: ' . $queue->getNumberOfRequestsToProcessAtSameTime());
var_dump('Should Process: ' . (int) $queue->shouldProcess());
var_dump('Get Num aquired locks: ' . $this->lock->getNumberOfAcquiredLocks());
if ($queue->shouldProcess() && $this->lock->acquireLock($this->currentQueueId)) {
var_dump('using queue');
return $queue;
}
}
} |
Here we are: ./console queuedtracking:processStarting to process request sets, this can take a while This worker finished queue processing with 0req/s (0 requests in 0.14 seconds) |
Thx a lot. I will get back to you on Monday. As I expected there seems to be a problem with this command: https://github.com/piwik/plugin-QueuedTracking/blob/master/Queue/Backend/Redis.php#L127 (http://redis.io/commands/set set with EX & NX option which is also recommended to implement a locking pattern http://redis.io/commands/set#patterns ). Do you know the version of the phpredis extension? You can possibly find out via |
Extension is 2.2.4, Redis is 3.0.4. |
Can you try to execute the following command on the server and post the output: Also can we debug the file public function setIfNotExists($key, $value, $ttlInSeconds)
{
var_dump('Key ' . $key);
var_dump('value ' . $value);
var_dump('ttl ' . $ttlInSeconds);
$this->connectIfNeeded();
$wasSet = $this->redis->set($key, $value, array('nx', 'ex' => $ttlInSeconds));
var_dump($wasSet);
return $wasSet;
} |
Sure. Btw, upgraded to Redis 3.0.5, but nothing changed. redis-cli SET Queued1 "Value" NX EX 5 Starting to process request sets, this can take a while This worker finished queue processing with 0req/s (0 requests in 0.00 seconds) |
OK your Redis server actually sends the correct response when executing |
Upgraded to 2.2.7, but still the same :( |
Thx. That's strange but I have one more idea. Can you execute the following commands and paste the output here? redis-cli get "QueuedTrackingLock0"
redis-cli keys "QueuedTrackingLock*" If any of these return a value you might try to execute (actually you can execute it either way) and test the redis-cli del "QueuedTrackingLock0" |
Here we are. $ redis-cli get "QueuedTrackingLock0" |
I'm running a bit out of ideas here. the problem seems to be in the Let's try a last test to see if we can find some more information. Can you update the execute method in protected function execute(InputInterface $input, OutputInterface $output)
{
$trackerEnvironment = new Environment('tracker');
$trackerEnvironment->init();
$settings = StaticContainer::get('Piwik\Plugins\QueuedTracking\Settings');
$host = $settings->redisHost->getValue();
$port = $settings->redisPort->getValue();
$timeout = $settings->redisTimeout->getValue();
$password = $settings->redisPassword->getValue();
$database = $settings->redisDatabase->getValue();
$backend = Queue\Factory::makeBackend();
$test = $backend->setIfNotExists('foo', 'bar', 1);
var_dump($test);
var_dump($backend->getServerVersion());
$redis = new \Redis();
$success = $redis->connect($host, $port, $timeout, null, 100);
if ($success && !empty($password)) {
var_dump('withpassword');
$success = $redis->auth($password);
var_dump($success);
}
if (!empty($database) || 0 === $database) {
var_dump('with database');
$redis->select($database);
}
var_dump($redis->set('testKey', 'value'));
var_dump($redis->set('testKeyWithttl', 'value', 5));
var_dump($redis->setnx('testnxkey', 'value'));
var_dump($redis->setex('testexkey', 5, 'value'));
var_dump($redis->set('testKeyWithNx', 'value', array('nx')));
var_dump($redis->set('testKeyWithEx', 'value', array('ex' => 5)));
var_dump($redis->del('testKey'));
var_dump($redis->del('testKeyWithttl'));
var_dump($redis->del('testnxkey'));
var_dump($redis->del('testexkey'));
var_dump($redis->del('testKeyWithNx'));
var_dump($redis->del('testKeyWithEx'));
$x = new \ReflectionExtension('redis');
var_dump('Redis version: ' . $x->getVersion());
var_dump('PHP version: ' . phpversion());
var_dump('Connected: ' . (int) $redis->isConnected());
} In my case the output looks like this
|
Here :) bool(false) |
Thanks for that. So it doesn't seem to set any value at all no matter what, at the same time it seems to add values to a list perfectly fine ( |
Interesting is this one
At The question is why was there a break of 20 seconds. It usually takes like 100ms to insert a tracking request. Also I find it a bit weird that it is like exactly 20.1 seconds which almost feels like it was waiting for 20 seconds as it is so close to the 20 seconds. Do you use any custom plugins or have you modified the code in some ways? Wondering if there's eg a It's a bit hard to debug without access to the server as it would be probably good to do a |
What you could also try would be to increase the |
Uhm, well, I changed it to 60 in both places and now it works... I don't have any plugin using Redis as I installed it specially for QueuedTracking (though it's also used for cache & session storage now). |
Are you using any other Piwik plugins? Also have you configured a different database for cache and session? |
Yes I do, but as I tried disabling them also, I don't think they somehow affect this. Yes, I configured different databases as it's mentioned in the configuration guide :) Here's the list of all active plugins:
|
Can you also try with 30 seconds instead of 60? If disabling all of the mentioned plugins doesn't have any affect there must be something else that makes it quite slow. I'll think about it but not sure what could make it that slow. Do you use the JavaScript tracker? |
Tried 30 - not working, changed to 35 (and 40) and it started processing. Yes, we use JS tracker. |
Is it processing the requests fast in general? Or is it adding more requests than it can process at the same time? You can monitor it with |
Well, it works fine for some time, then stops, does nothing for a while and then continues (e.g. it goes fast from 20000 until 14000, then waits for 10 seconds, then continues from 14000 until 5000, again waits for 10 seconds and then continues until the end). |
Sweet, thx for letting us know. Problem is after the next update you will have to update the timeout maybe again. I'm hoping the default 20 seconds timeout will work for you next time after all the records were processed now. I'm closing the issue and please let me know if you run into the issue again after an update. We'll then maybe need to increase the default timeout. |
although this is already closed... we had similar issues from time to time. Debugging was quite a pain. But finally strace showed that process timed out caused by failed reverse DNS lookups (dropping instead of rejecting TCP Port 53). Maybe this helps... |
Did the failed DNS lookup take a long time? I wonder where we do DNS lookups |
I think DNS lookups where triggered by "provider lookup". |
The Provider plugin should be disabled see https://github.com/piwik/plugin-QueuedTracking/blob/0.2.5/Commands/Process.php#L45 but it might not work anymore. I will create a new issue for this |
I tested it in #35 and Provider plugin should be disabled |
Hi guys, I've just run in the same issue (on the very same system that akrus was initially reporting from) and could not recover by raising ttls as suggested. |
Maybe check if you can see anything in the server logs or so? |
I'm sorry to repeat the research of akrus again but there is not much info in any logs or console debug messages. console just reports 0 workers and over 40k sets in queue, that's all. |
Hello, I faced the same issue. Solution: In Matomo->General Settings->QueuedTracking set below value: Number of requests that are processed in one batch=1. It will process all pending request for that worker slowly. |
While this is still searchable issue, we are continuing to observe this, due to the fact that, in case of any error in the processing step, the entire result would be represented incorrectly as 0 requests processed. In the same thread the following command helped to debug further:
It has generated a lot of output information, and fortunately we found the error - DEBUG: Visit is known (IP = 192.168.0.0) This worker finished queue processing with 0req/s (0 requests in 30.01 seconds) @tsteur, can you please consider this request to increase the datatype of visit_total_interactions from smallint to int ? |
I'm having the same issue, but haven't found a solution yet to fix it. This is the output of
Running
Then it sits there for a while and that's it. I'm using latest Matomo 3.9.1 and all plugins are up to date. System integrity check also says everything is fine. |
Can you check if it prints some requests? It might help to enable debugging logging for tracker: https://developer.matomo.org/api-reference/tracking-api#debugging-the-tracker |
I guess I've found the problem, it seems that the database is already quite full and get's slow, I'm doing a cleanup now and see if it makes it any better. |
While the symptoms might be the same, I'm thinking there are several distinct causes at play here. In my and @bhisecj 's case, the problem is simply that the number of items in the queue < |
As an update for anyone else that runs into this issue, I was experiencing the same issue and followed of the troubleshooting steps @tsteur recommended. Increasing the lock timeout time in Queue/Processor.php from 20 and 30 seconds to 60 seconds each appears to have the queue actually processing again. We were up to over 550k items in the 4 queues and that appears to be dropping now. I hope that helps someone else too. |
Hello!
We have a strange issue with this plugin - the queue itself seems to work fine, it has data in Redis (used all 2G of memory), but it's not inserted to database at all.
queuedtracking:print-queued-requests returns me a list of requests (but not full, just some of them)
And other output:
su www-data -c './console queuedtracking:monitor -vvv'
DEBUG [2015-10-29 08:41:08] UserSynchronizer::makeConfigured(): LDAP access synchronization not enabled.
DEBUG [2015-10-29 08:41:08] UserSynchronizer::makeConfigured: configuring with defaultSitesWithViewAccess =
Queue is enabled
Request sets in the queue will be processed automatically after a tracking request
Up to 1 workers will be used
Processor will start once there are at least 25 request sets in the queue
279662 (279662) request sets left in queue. 1.91G used memory (2.54G peak). 0 workers active. ^C
Session terminated, terminating shell... ...terminated.
su www-data -c './console queuedtracking:process -vvv'
DEBUG [2015-10-29 08:41:24] UserSynchronizer::makeConfigured(): LDAP access synchronization not enabled.
DEBUG [2015-10-29 08:41:24] UserSynchronizer::makeConfigured: configuring with defaultSitesWithViewAccess =
Starting to process request sets, this can take a while
This worker finished queue processing with 0req/s (0 requests in 0.00 seconds)
What's wrong with it? I've followed through the documentation several times and everything is correct...
Redis version is 3.0.4, php version is 5.5.9 (Ubuntu 14.04 LTS build), php-redis is 2.2.4.
The text was updated successfully, but these errors were encountered: