Connection issues with Couchbase PHP Extension, Couchbase 1.8.1
The servers are currently using v1.0.0 of the PHP Couchbase extension, and couchbase 1.8.1 community edition, build 937, on CentOS 5.4. In the logs, I frequently see these two types of errors:
Couchbase::__construct(): Failed to connect libcouchbase to server: Connection failure, referer: myniftyurlhere.com
Couchbase::get(): Faild to get a value from server: Operation timed out
We didn't have these issues with Memcached and Client-side Moxi. So I've begun testing Memcached & Client-side Moxi (1.8) to talk to the cluster. Unfortunately, when using the Memcached extension to read those values, I encounter this error:
$connection = new Memcached;
$connection->addServer('localhost', 11211);
$connection->get('testKey'); // saved using couchbase extension
print_r($connection->getResultMessage());
> Warning: Memcached::get(): could not decompress value in /test-script.php
> PAYLOAD FAILUREInterestingly, if I use netcat to talk on port 11211 to the client moxi, I get this:
[root@test ~]# echo 'get testKey' | nc localhost 11211 VALUE testKey 6 19 hello! @ 1354913089 END
Of course, reading the values using the existing PHP couchbase extension works. Oddly enough, when I compile and install Couchbase extension v1.0.6, or use the precompiled Centos 5.5 version, it also has a similar complaint:
Warning: Couchbase::get(): unknown payload type in test.php on line 8 Warning: Couchbase::get(): Failed to get a value from server: Generic error in test.php on line 8
What's the best way to address the connection errors? Should we be using client-side moxi? If so, what is the Couchbase extension using to compress the values such that Memcached cannot uncompress them? If not, how can I begin diagnosing the possible reasons why the Couchbase client can't connect to/read values from the Couchbase cluster?
Hi alex,
if you can, upgrade to the previously released 1.1 version: It is compatible with 1.8, has lots of enhancements and bugfixes and should allow you to move to 2.0:
http://www.couchbase.com/develop/php/current
Thanks,
Michael
The Couchbase 1.1.0 version of the php extension use a setting compatible with the memcached extension.
Hi, thanks for the responses,
This is somewhat unrelated, but I had a question about the documentation. I was under the impression that when set to true, the php extension will maintain a connection between calls to the interpreter. However, in the documentation there's this line:
"The Couchbase library has limited functionality for connecting to servers; it does not directly support vBuckets or SASL authentication. You can, however, configure multiple servers with associated weights (connection priorities) by specifying hostname, port and weight. One solution is to use client-side Moxi to act as a proxy service to the Couchbase Server cluster."
This seems to imply that it doesn't. What are the pros and cons of using client-side moxi versus using the couchbase php extension with regards to performance?
Just to be clear, this is a cluster that is always been using couchbase server & php extension.
This is somewhat unrelated, but I had a question about the documentation. I was under the impression that when set to true, the php extension will maintain a connection between calls to the interpreter. However, in the documentation there's this line:
"The Couchbase library has limited functionality for connecting to servers; it does not directly support vBuckets or SASL authentication. You can, however, configure multiple servers with associated weights (connection priorities) by specifying hostname, port and weight. One solution is to use client-side Moxi to act as a proxy service to the Couchbase Server cluster."
This seems to imply that it doesn't. What are the pros and cons of using client-side moxi versus using the couchbase php extension with regards to performance?
Just to be clear, this is a cluster that is always been using couchbase server & php extension.
I haven't looked at the documentation lately, but it seems to me that it is a bit obsolete. The PHP extension is built on top of libcouchbase which supports vbuckets and SASL authentication. Unless you specify the perisitent connection features you're going to end up connecting to the cluster, retrieve the cluster information, do SASL authentication to the correct bucket and get your data _EVERY_ time causing the performance to drop significantly. Do you have a link to where you found that piece in the documentation so I can file a bug for it to be updated?
Thanks, trond. The link is here: http://www.couchbase.com/docs/couchbase-sdk-php-1.1/couchbase-sdk-php-tu...
I was able to get persistent connections with the 1.0.6 extension. I did try to upgrade to 1.1.0 (I compiled from source), but ended up getting this error upon connection:
Couchbase::__construct(): failed to create IO instance error
Still, we met the goal of getting persistent connections working. The old 1.0.1 extension would segfault frequently when using it.
I was able to get persistent connections with the 1.0.6 extension. I did try to upgrade to 1.1.0 (I compiled from source), but ended up getting this error upon connection:
Couchbase::__construct(): failed to create IO instance error
Still, we met the goal of getting persistent connections working. The old 1.0.1 extension would segfault frequently when using it.
Where did you install the library? please note that the couchbase php plugin tries to open the libcouchbase_XXX (libevent/libev plugin) so those modules need to be in the search path for the runtime linker from PHP...
You could try to just copy them to /usr/lib and see if that resolves your problem (Or build libcouchbase with -Wl,rpath,/path/to/your/installation/lib/dir)
Hope this helps
I was able to diagnose the issue. There haven't been any responses, but this may be helpful to others who have to make this change. I noticed that there's no documentation for this breaking change.
For non-scalar datatypes(and possibly more, I've only tested with serialized data), Couchbase PHP Extensions 1.0.0-1.0.2 (maybe earlier) save different flags using the memcache set command than in later versions. In the memcached protocol, you can optionally save flags and have them be read by the client. If you get the unknown payload type error, in the prompt type:
$ echo 'get testKey' | nc $SERVER_SIDE_MOXI_URL 11211 VALUE testKey 31 19 O:8:"stdClass":0:{} ENDThe number after testKey indicates the flags the value was saved with. It should be 4, not 31, to be read by later versions of the Couchbase PHP extension.