Skip to content
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

json_decode error in workers #33

Closed
kballenegger opened this issue Dec 23, 2011 · 6 comments
Closed

json_decode error in workers #33

kballenegger opened this issue Dec 23, 2011 · 6 comments

Comments

@kballenegger
Copy link

Getting the following warning in the workers:

PHP Warning:  json_decode() expects parameter 1 to be string, array given in /var/www/server/releases/20111223123758/vendor/resque/lib/Resque.php on line 85

Which seems to trace back to Resident::__call. Not sure what's going on there, and I don't know the internals of Redis enough to know why it's trying to json_decode a string rather than an array. Fwiw, jovs are added by doing Resque::enqueue($queue, $class, $args); where $args is always an array.

Thoughts?

@andrewjshults
Copy link
Contributor

Which version of Redis and php-resque are you running? Redisent is a pretty lightweight wrapper around the Redis protocol. From looking at Redisent::__call, the only situation that it should return an array is if it got a multi bulk reply (http://redis.io/topics/protocol#multi-bulk-reply).

Could you take a look at what Redis command Redisent is trying to run (on mine, it's line 73 in lib/Redisent/Redisent.php). The worker should be running LPOP to pull items off the queue which should (as far as I can tell) return a bulk reply but not a multi-bulk reply (since it should only be returning one element at a time).

@kballenegger
Copy link
Author

Should have mentioned this before, but this is for the LPOP.

I just checked this on redis-cli.

redis 127.0.0.1:6379> lpop resque:queue:api
"{\"class\":\"ApiQueueWorker\",\"args\":[{\"type\":\"install\",\"data\":{\"sdk\":\"2.5.7\",\"os\":\"5.0.1\",\"uuid\":\"7ebec17bb2584489d0390a0e0b6c92575dc778ec\",\"app\":\"4ebb12775d2b94047d000000\",\"ui\":\"1\",\"signature\":\"a4618a79d1dabc8987c5da6e81bebd72\",\"country\":\"US\",\"bundle\":\"1.3.0\",\"language\":\"en\",\"model\":\"iPad\",\"date_created\":1324644314,\"queue_type\":\"installs\"}}],\"id\":\"4500e90b417df4f652be1ee7f1892f38\"}"

Looks like redis is returning a bulk-reply alright, when I try doing an lpop manually off redis. Not too sure what the deal is here.

@chrisboulton
Copy link
Owner

This should be fixed by changes introduced in 1.2, specifically with the detection of when php-resque forks and needs to reconnect to Redis. If this is still happening on 1.2, let me know.

@alexdemers
Copy link

I just had the same issue. My process was running for the past 4 days.

@chrisboulton
Copy link
Owner

@alexdemers, hmm - you're definitely running the latest version? How do you start your workers? With the built in worker manager (COUNT > 1), or using monit/God/etc (with COUNT=1)?

@alexdemers
Copy link

I run the latest version of php-resque as of today. Redis is 2.4.17 which was the stable release about 3 weeks ago.

I have an executable script which simply has:

<?php
date_default_timezone_set('UTC');

putenv('REDIS_BACKEND=xxx.xxx.xxx.xxx');
putenv('REDIS_DATABASE=0');
putenv('QUEUE=*');

require 'resque.php';

So, I don't do anything with the COUNT except the default behavious when none is supplied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants