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

PHP Couchbase persistent connections shares more than expected

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0-dp1
    • Component/s: library
    • Security Level: Public
    • Labels:
      None

      Description

      PHP Couchbase persistent connection shares all option settings (serializer, compression, prefix_key) and keeps that settings across multiple requests. This is not an expected behaviour.

      Code:

      <?php
      $cb1 = new Couchbase("http://192.168.0.180/default");
      $cb2 = new Couchbase("http://192.168.0.180/default");

      $cb1->setOption(COUCHBASE_OPT_PREFIX_KEY,'cb1');
      $cb2->setOption(COUCHBASE_OPT_PREFIX_KEY,'cb2');

      $cb1->set('val1','v1', 60);
      $cb2->set('val2','v2', 60);
      ?>

      will store following keys:

      cb2_val1
      cb2_val2

      Moreover if you execute right after previous request following code (in another script):

      <?php
      $cb = new Couchbase("http://192.168.0.180/default");
      $cb->set('val3','v3', 60);
      ?>

      the code stores key:

      cb2_val3

      If you turn off the persistent connections, you will get more consistent results:

      cb1_val1
      cb2_val2
      val3

      The problem is that whole _php_couchbase_res structure is shared when using persistent connection. Possible change is to duplicate this structure in php_couchbase_create_impl. But resource destructors should be modified according to this change.

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

        Activity

        Hide
        brett19 Brett Lawson added a comment -

        Due to the underlying implementation of the SDK, it is non-trivial to allow persistent connections to separate some options. However, as of 2.0.0-dp1, any options which are 'global' across persistent connections to the same cluster are advertised as such.

        Show
        brett19 Brett Lawson added a comment - Due to the underlying implementation of the SDK, it is non-trivial to allow persistent connections to separate some options. However, as of 2.0.0-dp1, any options which are 'global' across persistent connections to the same cluster are advertised as such.

          People

          • Assignee:
            brett19 Brett Lawson
            Reporter:
            jtulach jtulach
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes