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

PhpiRedis: supplied resource is not a valid phpredis reader #55

Open
indytechcook opened this issue Jan 21, 2017 · 1 comment
Open

PhpiRedis: supplied resource is not a valid phpredis reader #55

indytechcook opened this issue Jan 21, 2017 · 1 comment

Comments

@indytechcook
Copy link

First, thank you for all of your hard work.

Thread moved from predis/predis#410

Here is my setup:

  • ubuntu 16.04 LTS
  • php 7.0.14
  • predis: v1.1.1
  • redis version 3.2 on AWS Elastic Cache
  • Cluster mode in AWS with 3 masters and one replication on each master
  • phpiredis version: from v1.0 branch
  • hredis version: v0.13.3
  • drupal7 with custom Factory Cache class:
  • Redis Config:
    ** activerehashing: yes
    ** appendfsync: everysecond
    ** appendonly: no
    ** client-output-buffer-limit-normal-hard-limit: 0
    ** client-output-buffer-limit-normal-soft-limit: 0
    ** client-output-buffer-limit-normal-soft-seconds: 0
    ** client-output-buffer-limit-pubsub-hard-limit: 33554432
    ** client-output-buffer-limit-pubsub-soft-limit: 8388608
    ** client-output-buffer-limit-pubsub-soft-seconds: 60
    ** client-output-buffer-limit-slave-soft-seconds: 60
ubuntu@ip-10-2-12-205:~$ php -v
PHP 7.0.14-2+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.14-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
    with blackfire v1.14.2~linux-x64-non_zts70, https://blackfire.io, by Blackfireio Inc.

Client Build:

This first array is passed in the first argument to Client

$conf['redis_servers'] = [
  [
    'scheme'   => 'tcp',
    'host'     => 'hostname-of-master-1,
    'port'     => 6379,
    'timeout' => 30,
  ],
  [
    'scheme'   => 'tcp',
    'host'     => 'hostname-of-master-2,
    'port'     => 6379,
    'timeout' => 30,
  ],
  [
    'scheme'   => 'tcp',
    'host'     => 'host-name-of-master-3',
    'port'     => 6379,
    'timeout' => 30,
  ]
];

Options array

$conf['redis_options'] = [
  'cluster' => 'redis',
  'connections' => [
    'tcp'  => 'Predis\Connection\PhpiredisStreamConnection',
    'unix' => 'Predis\Connection\PhpiredisSocketConnection',
  ],
];

Error which occurs:

"Warning: phpiredis_reader_get_state(): supplied resource is not a valid phpredis reader resource in Predis\\Connection\\PhpiredisStreamConnection->read() (line 200 of composer/vendor/predis/predis/src/Connection/PhpiredisStreamConnection.php

The error occurs inconsistently. I've seen it mostly in hgetall which is also the most common call

What I have tried:

  • Changing the timeout value from 5 to 30. I thought perhaps the there is a timeout.
  • Removing the connections does remove the error
  • Changing to the trigger_errors to false in client options and the error still occurs

More info

Adding a bit more information, it phpiredis was also crashing the php-fpm processes even with commenting out the "connections". Once I disabled the extension, I was able to keep the php-fpm processes running. I'm happy to move this issue over to the other project if you feel that is best.

 /* 'connections' => [
    'tcp'  => 'Predis\Connection\PhpiredisStreamConnection',
    'unix' => 'Predis\Connection\PhpiredisSocketConnection',
  ],*/
@nrk
Copy link
Owner

nrk commented Jan 29, 2017

As I said on the other issue, what makes this really strage is that PHP crashes even without actually using phpiredis (when you comment the connections option in Predis, it just uses the default stream-based + pure-PHP protocol parser backend) which means there's probably something going on when the extension is initialized or something.

Your setup seems pretty much standard and phpiredis has been tested multiple times against a very similar setup, there's just one different thing that I noticed: you are using the blackfire extension. I've never used blackfire.io and I don't have an account with them, it would be of great help if you could try disabling the extension (maybe on a different server than the ones in production, just for testing) and see if anything changes.

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

2 participants