It appears that under certain circumstances the PHP SDK can begin returning null for operations (e.g. get, upsert).
This circumstance is where a PHP request is prematurely terminated while performing an operation within the SDK, at least when running under Apache, I haven't tested with php-fpm or nginx.
This can be replicated very easily using the following PHP script (modified version of 'Hello Couchbase'):
The idea of this script is to trigger the max_execution_time by looping on the get endlessly which will then terminate the request.
There is then also special logic to check if the result is ever null and if so report it to the user.
If you request the page and then a few seconds later request it again (in a different tab), after a while the max execution time of the first page will be hit and then the second page will display the null message.
To make it easy to reproduce and see the results of this, I have created a docker image which runs the script above within Apache.
You can run it as follows, obviously you must have a reachable CB instance running:
You can then access the page at http://localhost:8080/index.php
I suspect what's happening here is that the underlying (shared) libcouchbase object somehow becomes disposed/corrupted as a result of the first request terminating prematurely and then the other request sharing it can no longer use it (hence return null).
If this is the case then I'm not sure what the best way to handle it would be, but at the very least I would expect an explicit error message get returned to the user, rather than failing 'silently' by returning null.
|For Gerrit Dashboard: PCBC-518|
|87388,2||PCBC-518: Detect and cleanup connections left in bad state||master||php-couchbase||Status: MERGED||+2||+1|