[PCBC-104] PHP Client Need to Catch and Process "Object Too Large"errors from libcouchbase Created: 25/Aug/12  Updated: 04/Dec/12  Resolved: 03/Dec/12

Status: Resolved
Project: Couchbase PHP client library
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1.0
Security Level: Public

Type: Bug Priority: Major
Reporter: xing Assignee: Trond Norbye
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment: PHP client DP3

Problem Summary:

When writing more than 1MB of data using php libcouch client, the client itself does not process the object too large error and the libcouchbase library logs a PHP warning as "PHP Warning: Couchbase::set(): Failed to store a value to server: Object too big in.....".

As result, it's impossible to write a strict warning free high performance php app using the current setup when we can't control what data is attempted to be cached.

1) We cannot catch this error before passing data in since more >1MB data might be compressible to less than <1MB so we have to rely on the PHP Client to do this for us.
2) We cannot catch this on the client site since it's not an exception but a PHP error/warning.
3) We can use set_error_handler() in php to catch this but it is extremely slow and negates the performance advantage of having libcouchbase in the first place.


1) Return FALSE from PHP Client if post-compressed data is more than 1MB.

/* INSERT CODE test for payload_len size here before calling line below, if more, than return FALSE */

if (!(payload = php_couchbase_zval_to_payload(value, &payload_len, &flags, couchbase_res->serializer, couchbase_res->compressor TSRMLS_CC))) {

Notes: pecl-memcached using libmemcached lib does not throw PHP warnings when object size is over limit. Error is logged internally and is up to the programmer to read the error post-fail to determine what happened.

Comment by xing [ 25/Aug/12 ]
1) Typos. The test code should happen after, not before, the zval_to_payload conversion which is when we know exactly is data is over limit.

2) Since libcouchbase supports I believe 10MB for disk based buckets, my report only deals with ram buckets. Perhaps there is a test somewhere for bucket type before size compare.
Comment by Michael Nitschinger [ 25/Aug/12 ]
Hi xing,

thanks for taking the time to open an issue!

Just to recap - you are using the following setup:

- PHP SDK 1.1-dp3
- Couchbase 2.0-dp4 (am I right?)

Are you using a couchbase bucket or a memcached bucket? The couchbase bucket is definitely capable of handling files larger than 1MB.

There is some restructuring going on regarding the warning/exception handling in the PHP SDK, but let's first sort out your particular issue here.

Thanks, Michael
Comment by Matt Ingenthron [ 07/Nov/12 ]
Trond: assigning to you to determine if still an issue and triage.
Comment by Trond Norbye [ 03/Dec/12 ]
This is no longer a problem. You can either catch the exception thrown by the object oriented interface, or you can call couchbase_get_result_code() and it'll contain e2big
Comment by kzeller [ 04/Dec/12 ]
PHP Client now catches and processes 'object too larger' errors
Added to RN coming from underlying C library.
Generated at Tue Oct 21 07:52:08 CDT 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.