Thanks Jonathan It looks like applying just the second patch from THRIFT-638 ( https://issues.apache.org/jira/browse/THRIFT-638) fixes the issue for me.
The logic in the patch being: if there is less unread bytes than the number we have been asked to read, adjust down the number of bytes to read accordingly. https://issues.apache.org/jira/secure/attachment/12447870/0002-tocket-read-meta-data-check.diff Dave On 9 February 2011 17:46, Jonathan Ellis <[email protected]> wrote: > PHPCassa uses the patches from THRIFT-867 and THRIFT-638 and doesn't > have timeout problems. > > On Wed, Feb 9, 2011 at 4:41 AM, Dave Gardner <[email protected]> > wrote: > > Hi all > > > > I remember coming across a Thrift issue with PHP ages ago, whilst reading > > data from Cassandra. The problem was that if the amount of data returned > > (eg: in bytes) was over a certain threshold, it would always take an > amount > > of time exactly equal to the socket timeout to receive the data. If the > > amount was below this threshold, it would take very little time at all. > I > > don't remember why we never got to the bottom of the issue at that time, > but > > today it is causing me issues again. > > > > I had a look through Jira and found this, which sounds like the problem: > > > > https://issues.apache.org/jira/browse/THRIFT-347 > > > > I then downloaded Thrift 0.6.0 yesterday, downloaded the Cassandra 0.6.6 > > Thrift interface and then built the PHP API from interface (after > tweaking > > as per this message: > > http://www.mail-archive.com/[email protected]/msg07089.html). > > > > However, this doesn't appear to have fixed the issue. > > > > So... what I have done is tweak TSocket.php as per: (look for // ADDED) > > > > http://pastebin.com/5m1nShtE > > > > And then tried out running our app with various timeouts set. This is the > > code that sets timeouts: > > > > http://pastebin.com/TXJAVVnt > > > > The results are: > > > > http://pastebin.com/5gWTPCHd > > > > Things to note: > > > > - More Cassandra reads than listed here happen; however those returning > > less data will happen very quickly > > - It would be handy if the generated PHP files contained the version of > > Thrift they were built from within the header; currently it can be tricky > to > > be certain that you have the right files > > > > > > So it seems as thought fread() is having issues. I was wondering if > anyone > > else had experienced this? Is it a problem with the server (eg: Cassandra > > 0.6.6) or is it a problem with the Thrift TSocket.php code? > > > > Any help appreciated. > > > > Thanks > > > > Dave > > > > > > -- > Jonathan Ellis > Project Chair, Apache Cassandra > co-founder of DataStax, the source for professional Cassandra support > http://www.datastax.com >
