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

If the PHP memory limit is hit whilst in the SDK then lcb can be left in an invalid state

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.1.0
    • None
    • library
    • Security Level: Public
    • None

    Description

      If the PHP memory limit is hit whilst in the SDK then the libcouchbase object in use can be left in an invalid state.

      Recreation, use Nginx + PHP-FPM and run (May need to refresh a few times to use up all of FPM's child processes):

      ```
      <?php
      $cluster = new CouchbaseCluster('couchbase://192.168.56.1');
      $bucket = $cluster->openBucket('default');

      // Creates a 30+mb string, set larger if needed
      $doc = str_repeat("0", pow(2,25));
      $bucket->upsert('hello', $doc);
      var_dump($bucket->get('hello'));
      ```

      This will effectively break all future connections to that bucket for that process as the lcb_t object is broken. In this situation the SDK starts to return null.

      I suspect this is from emalloc failing in the SDK function but PHP not ending the request until the SDK returns. Since lcb is malloc'd itself it can retain this invalid state between requests.

      Possible mitigation here, but it would be nice to check if emalloc succeeded as well:
      https://github.com/couchbaselabs/php-couchbase/pull/9

      Attachments

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

        Activity

          People

            brett19 Brett Lawson
            will.gardner Will Gardner (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty