duoshuo / php-cassandra

php Cassandra driver which support Protocol v3 (Cassandra 2.1) and asynchronous requests
MIT License
153 stars 53 forks source link

Socket::read() can get stuck reading 0 bytes in a loop #41

Open arnaud-lb opened 9 years ago

arnaud-lb commented 9 years ago

I've seen multiple PHP processes getting stuck in a loop here when the cassandra node goes down.

Apparently, socket_read() returns an empty string when the other side has closed the connection.

arnaud-lb commented 9 years ago

socket_read() uses recv(), which is documented to return 0 if the peer has performed an orderly shutdown.

When recv() returns 0, PHP returns an empty string.

gonzaloserrano commented 9 years ago

I think this fix fixes somewhat https://github.com/duoshuo/php-cassandra/issues/36 due to avoiding the infinite loop reported.

shen2 commented 9 years ago

It seems your Cassandra version is 2.0.x. php-cassandra supports Cassandra 2.1 or later.

locked commented 9 years ago

We have this issue too, for example if we restart a cassandra node while php was connected. We use cassandra 2.1.