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
error with LIST: protocol error, got '{' as reply type byte #52
Comments
Hi Steve, '{' looks like the first character of some data, not really what one would expect to see in the Redis protocol. Do you know more about the conditions in which this happens? I will try running tests in parallel but if you have some code to reproduce the issue that would be perfect. Thanks. |
Hi Nicolas, The "{" is part of json_encode string, and it works elsewhere normally. Please note, the bug I reported earlier ONLY happens when I have called pcntl_fork(). Below is the two files I've just made to make it simple: daemon.php is the worker that loops infinitely to pop job and perform. gen_job.php can be run as "gen_job.php 3" to push 3 jobs to the queue named "queue". Gist: https://gist.github.com/1241970 HOW TO RUN
BUGS
steve@clu3:~/Code/git/xxx/public$ php daemon.php start loop @ 16:59:15 start loop @ 16:59:20 start loop @ 16:59:23 --- END of LOG---
NOTE: So I'm not sure what exact problems fork() is causing here Thanks Nicolas |
Ah, very interesting. I guess that after fork(), the two PHP processes keep using the same socket, which is shared. You are seeing a race condition between two processes trying to read from the same socket. You should reconnect to Redis after the fork(), I expect this will fix your issue. |
Thanks Nicolas, However, I still don't understand why there should be a race condition since only the parent is accessing the queue. Even if the redis connection is available to the child, the child is not using it (child only performs the job), so it shouldn't affect the parent reading the socket. I think there's still something weird here |
Hi Nicolas,
I am trying to implement a Message Queue (job queue) using the master branch phpredis with latest redis, and working with LIST
Suppose my queue name is "queue:high". During the process of pushing and popping my test item (which is a json_encoded string) sometimes I get this RedisException
protocol error, got '{' as reply type byte
I unfortunately cannot find out exactly when this happen but my guess is it has to do with the 2 processes trying to pop one item from the list. That's actually the only thing I could think of
(My main worker loops indefinitely to pop items from the queue)
Please let me know if I need to provide anything else. Thank you Nicolas
The text was updated successfully, but these errors were encountered: