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

Call to bucket.counter() without delta results in segmentation fault

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.1
    • Fix Version/s: 2.3.2
    • Component/s: None
    • Labels:
      None
    • Environment:
      PHP 7.1

      Description

      http://docs.couchbase.com/sdk-api/couchbase-php-client-2.3.1/classes/Couchbase.Bucket.html#method_counter

      Invoking bucket->counter('customer::counter') results in PHP shutting down and reporting "segmentation fault: 11" to the command line.

      $app->post('/api/customer', function($request, $response, $args) {

        $jsonDocType = $request->getAttribute('jsonDocType');
        $jsonBody = $request->getParsedBody();
        // $docId = $jsonDocType . '::' . $jsonBody['username']; // . uniqid();

        $increment = $this->bucket->counter('customer::counter');
        var_dump($increment); die();

       

      });

       

       

      Invoking either bucket->counter('customer::counter', 1) or bucket->counter('customer::counter', 1, ['1']) results in LCB_KEY_ENOENT: The key does not exist on the server.

      In our other SDKs, the first use of bucket.counter() causes the counter document to be created if it does not already exist, with a default value of 1 and a default increment of 1. 

      $app->post('/api/customer', function($request, $response, $args) {

        $jsonDocType = $request->getAttribute('jsonDocType');
        $jsonBody = $request->getParsedBody();
        // $docId = $jsonDocType . '::' . $jsonBody['username']; // . uniqid();

        // $increment = $this->bucket->counter('customer::counter', 1, ['1']);
        *  *$increment = $this->bucket->counter('customer::counter', 1);**

        var_dump($increment); die();

       

      });

        Attachments

        For Gerrit Dashboard: PCBC-481
        # Subject Branch Project Status CR V

          Activity

          Hide
          ingenthr Matt Ingenthron added a comment -

          Michael Nitschinger or Brett Lawson: do we have a cross SDK consistency issue here?

          Show
          ingenthr Matt Ingenthron added a comment - Michael Nitschinger or Brett Lawson : do we have a cross SDK consistency issue here?
          Hide
          avsej Sergey Avseyev added a comment -

          nodejs consistent
          https://github.com/couchbase/couchnode/blob/c2eae98afca14c1a0298248c036b9c7e05db2d9c/lib/bucket.js#L1739

          I wonder how they switch this initial off? passing null for it? This would be ugly for php.

          Show
          avsej Sergey Avseyev added a comment - nodejs consistent https://github.com/couchbase/couchnode/blob/c2eae98afca14c1a0298248c036b9c7e05db2d9c/lib/bucket.js#L1739 I wonder how they switch this initial off? passing null for it? This would be ugly for php.
          Show
          avsej Sergey Avseyev added a comment - python also consistent https://github.com/couchbase/couchbase-python-client/blob/2dc82f7987776bdd062ce2ce8ab0023ea66eea4a/couchbase/tests/cases/arithmetic_t.py#L47
          Show
          avsej Sergey Avseyev added a comment - but java is not https://github.com/couchbase/couchbase-java-client/blob/master/src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java#L887-L890 it specifies zero as initial value
          Hide
          leo.schuman Leo Schuman [X] (Inactive) added a comment -

          Thank you for looking into this. My recollection was from building similar behavior using the Java SDK last year. I misremembered the initial value as 1 rather than 0.

          Show
          leo.schuman Leo Schuman [X] (Inactive) added a comment - Thank you for looking into this. My recollection was from building similar behavior using the Java SDK last year. I misremembered the initial value as 1 rather than 0.

            People

            • Assignee:
              avsej Sergey Avseyev
              Reporter:
              leo.schuman Leo Schuman [X] (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes

                  PagerDuty

                  Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.