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

getReplica() unpredictable behavior array_key_exists() implementation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Critical
    • None
    • 1.2.2
    • library
    • Security Level: Public
    • None
    • - Centos 6.5 X86_64
      - PHP 5.5.12
      - libcouchbase version => 2.3.1

    Description

      I'm planning to use Couchbase as a PHP session storage. In the current test setup I've two Couchbase nodes with one node in "Down" state. The data isn't rebalanced yet.

      Unfortunately the array which is returned in the getReplica() in unpredictable. The function array_key_exists() return sometimes bool(true) - the expected value - but sometimes the value is bool(false).

      An example of the implementation is added:

      PHP snippet:
      ==========
      <?php
      class CouchbaseSessionHandler implements SessionHandlerInterface
      {
      public function read($id)
      {
      try

      { $sessionData = $this->connection->get($id); }

      catch (CouchbaseLibcouchbaseException $ex) {
      try

      { $replicaDocument = $this->connection->getReplica($id, COUCHBASE_REPLICA_FIRST); var_dump($id); var_dump($replicaDocument); var_dump(is_array($replicaDocument)); var_dump(array_key_exists($id, $replicaDocument)); .... }

      catch (CouchbaseLibcouchbaseException $ex)

      { return null; }

      }
      }

      }

      Output (the unexpected one):
      =====================
      string(26) "do8uaf0omfsjframmu95cc1dm1"
      array(1) { ["do8uaf0omfsjframmu95cc1dm1"]=> array(2)

      { ["cas"]=> string(20) "14545271133902995456" ["value"]=> string(944) "Some sessiondata";}

      " } }
      bool(true)
      bool(false)

      Attachments

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

        Activity

          People

            brett19 Brett Lawson
            hdanes Harry Danes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty