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

    • Task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.3.1
    • 2.3.2
    • None
    • None
    • 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

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

        Activity

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

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

          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.

          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.
          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
          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

          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.

          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

            avsej Sergey Avseyev
            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