Details

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:

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.

date/time support => enabled
"Olson" Timezone Database Version => 0.system
Timezone Database => internal
PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in Unknown on line 0
Default timezone => America/Los_Angeles

PHP License
This program is free software; you can redistribute it and/or modify
it under the terms of the PHP License as published by the PHP Group
and included in the distribution in the file: LICENSE

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you did not receive a copy of the PHP license, or have any
questions about PHP licensing, please contact license@php.net.

It doesn't work even when the extension is compiled to use fastlz compression.

I recompiled php-ext-couchbase from git with current libcouchbase code, and configured to include fastlz support. I set couchbase.compressor=fastlz in php.ini. And the couchbase.compression_threshold is at 2000, same as the memcached extension setting.

Excerpt of phpinfo() for the couchbase extension:

couchbase support enabled
version 1.1.0-dp5
json support yes
fastlz support yes
zlib support yes

Tim Smith (Inactive)
added a comment - 02/Nov/12 2:08 PM It doesn't work even when the extension is compiled to use fastlz compression.
I recompiled php-ext-couchbase from git with current libcouchbase code, and configured to include fastlz support. I set couchbase.compressor=fastlz in php.ini. And the couchbase.compression_threshold is at 2000, same as the memcached extension setting.
Excerpt of phpinfo() for the couchbase extension:
couchbase support enabled
version 1.1.0-dp5
json support yes
fastlz support yes
zlib support yes
Directive Local Value Master Value
couchbase.compression_factor 1.3 1.3
couchbase.compression_threshold 2000 2000
couchbase.compressor fastlz fastlz
couchbase.serializer php php
The same test case fails in the same way:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 7598212603105511377 bytes) in /usr/share/nginx/html/cb.php on line 35

Mark Nunberg
added a comment - 02/Nov/12 2:41 PM Fixes for this are in progress.
http://review.couchbase.org/#/c/20604/ (in progress) fixes some of the crazy allocation attempts you've seen.
As for fastlz support, it shouldn't be too difficult to add it on.

Mark Nunberg
added a comment - 06/Nov/12 8:43 PM A binary is attached. It's not compiled against the exact same version of php, but the zend api versions remain the same.
If the binary release doesn't work, I'd be happy to walk someone through building it from source (it's a very simple process – much simpler than getting this binary built).

Matt Ingenthron
added a comment - 07/Nov/12 3:22 PM Mark: Please determine if this issue is still valid and help me triage it into the appropriate release. I've assigned it to you for triage, not necessarily to fix it.

Tim Smith (Inactive)
added a comment - 15/Nov/12 12:32 PM More detail. I was personally unable to get the build of the latest PHP code to work with the beta2 release. I was hitting the error that is reported on http://www.couchbase.com/issues/browse/CCBC-126 :
Warning: Couchbase::__construct() [couchbase.--construct] : failed to create IO instance in /usr/share/nginx/html/cb.php on line 18
Building from sources let me get past that and actually test the build that the customer was trying. And following from that was a need to deal with LD_LIBRARY_PATH and symlink hacks.
A backport of the fastlz compression fix to 1.0.x, with an official release of that, would be best for this particular user's needs. Can we get an ETA on when that will be available?
Thanks,
Tim

Tim Smith (Inactive)
added a comment - 16/Nov/12 6:02 PM I've confirmed it to work (using the current 1.0.x branch from github.com/couchbase/php-ext-couchbase).
I had to create a fake /usr/lib64/libvbucket.la to get it to compile: http://www.couchbase.com/issues/browse/CCBC-127
I noticed that compress.c has this redundant (unused) definition:
92 /* headers which claim an uncompressed size above this figure are bad */
93 #define DECOMP_SANITY_LIMIT 0x40000000
And this inaccurate comment:
172 /**
173 * sanity check, don't allocate over a GB, we should make this number
174 * smaller though
175 */
Obviously minor cleanup stuff, nothing significant that I can spot.
Would be great to get a 1.0.x package built and available for download with this (and other critical fixes, like PCBC-75 ) available to customers. Is there an ETA on when that can be done?
Tim