Uploaded image for project: 'Couchbase PHP client library'
  1. Couchbase PHP client library
  2. PCBC-139

PHP client needs fastlz compression to be compatible with legacy memcached clients


    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.0.4
    • Fix Version/s: 1.1.0
    • Component/s: library
    • Security Level: Public
    • Labels:
    • Environment:
      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.


      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>
      <meta charset="utf-8">
      <title>Couchbase Server PHP Test</title>


      $host = "";
      $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)

      { // No servers, this pool needs to be configured $mc->addServer($host, 11211); //$mc->addServer("other host", 11211); }

      // Change this to 1999 and it will work
      $valLength = 2000;
      $val = date(DateTime::RFC2822) . ' ';
      $val .= str_repeat('X', $valLength - strlen($val));

      $mc->set("a", $val);
      echo("The value for 'a' is: ");


      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.

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.


        There are no open Gerrit changes for this issue.


          • Assignee:
            trond Trond Norbye
            TimSmith Tim Smith (Inactive)
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created:

              Time Tracking

              Original Estimate - 16h
              Remaining Estimate - 16h
              Time Spent - Not Specified
              Not Specified

                Gerrit Reviews

                There are no open Gerrit changes