Details
-
Bug
-
Resolution: Fixed
-
Blocker
-
1.0.4
-
Security Level: Public
-
With both php-ext-couchbase-1.0.5-centos55-x86_64.tar.gz and php-ext-couchbase-1.0.6b23_centos-5.5-x64.tar.gz. I will attach php -i output as a separate comment. Using php-pecl-memcached extension 1.0.0. libmemcached 1.0.4.
Description
The existing memcached clients for PHP (pecl-memcached and memcache) both default to using fastlz compression for values >= 2000 bytes.
The couchbase client library doesn't have fastlz compression included. It doesn't provide a useful error message when it runs into this problem. Instead, it misinterprets the stored value, tries to allocate a huge block of memory and fails. The error it gives (look, e.g., in the PHP-FPM web-access.log) is:
[01-Nov-2012 20:45:49 UTC] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 8460104323416721361 bytes) in /usr/share/nginx/html/cb.php on line 32
To reproduce, just set a value >= 2000 bytes with pecl-memcached client, and try to read it with Couchbase client. Here's a sample:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Couchbase Server PHP Test</title>
</head>
<body>
<p>
<?php
$host = "10.4.2.15";
$user = "Administrator";
$password = "password";
$bucketName = "default";
$persistConnection = false;
$cb = new Couchbase($host . ":8091",
$user, $password, $bucketName, $persistConnection);
$mc = new Memcached('Pool-1');
if (count($mc->getServerList()) == 0)
// Change this to 1999 and it will work
$valLength = 2000;
date_default_timezone_set('UTC');
$val = date(DateTime::RFC2822) . ' ';
$val .= str_repeat('X', $valLength - strlen($val));
$mc->set("a", $val);
echo("The value for 'a' is: ");
var_dump($cb->get("a"));
?>
</p>
</body>
</html>
The correct behavior is for the Couchbase client to ship, out of the box, compatible with existing Memcached client implementations. It should include fastlz support directly, or else clearly document how to add such support without requiring any unusual compilations or other hoops. The fastlz code is very small and portable, and hasn't changed since 2007, so it should present a minimal maintenance issue.
In addition, the PHP client documentation should clearly indicate what changes are needed in order for the client to be compatible with the other Couchbase clients (Java, .NET, etc.). Again, without requiring recompilation or extra hoops to jump through.