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

Persistent connections should be indexed on server list contents, not their order.


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.4, 1.1.2
    • Fix Version/s: 1.1.3
    • Component/s: library
    • Security Level: Public
    • Labels:


      In the current state, we simply treat the connection parameter as a string.

      An example use case may be of several clients trying to load-balance between various entry points nodes (EPTs). Such a strategy ensures that they aren't all hitting the same node for configuration requests.

      However when attempting to use this in conjunction with persistent connections, we have the consequence that each permutation of the "Server List" is treated as a separate key when using persistent connections; therefore something like:

      $base_list = array("", "", "", "");

      for ($i = 0; $i < 1000; $i++)

      { $cur_list = $base_list; shuffle($cur_list); $cb = new Couchbase($cur_list, "", "", "", true); $cb->set("foo", "bar"); // other operations }

      In a nutshell, this code has a "base" set of four servers. In the "normal" initialization code, the list is copied and then shuffled around, so that the first server in the list is always something else. Since the first server in the list ends up becoming the EPT (unless the server is down, in which case the next node is used, etc.) this enables some kind of cheap load balancing.

      However this also means the order of the array is different, which means the "canonical connection key" is different, which means that when considering whether an existing connection is available, a new one is created. Since we have 4 servers in the list, there is a potential of having 4*4=16 different client objects per process. These objects will never die.

      The solution is then to "deconstruct" the connection string in such a way that the server list itself is always alphabetically sorted. The effective list (When actually connecting) will remain the same, but for indexing purposes, it shall be sorted.

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


        mnunberg Mark Nunberg created issue -
        ingenthr Matt Ingenthron made changes -
        Field Original Value New Value
        Assignee Matt Ingenthron [ ingenthr ] Trond Norbye [ trond ]
        ingenthr Matt Ingenthron made changes -
        Planned End (re-schedule end date based on new assignee)
        ingenthr Matt Ingenthron made changes -
        Fix Version/s 1.1.3 [ 10452 ]
        ingenthr Matt Ingenthron made changes -
        Planned Start (set to new fixed version's start date)
        Planned End (set to new fixed version's start date)
        trond Trond Norbye made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        trond Trond Norbye made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        brett19 Brett Lawson made changes -
        Workflow jira [ 24542 ] Couchbase SDK Workflow [ 44408 ]


          • Assignee:
            trond Trond Norbye
            mnunberg Mark Nunberg
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created:

              Gerrit Reviews

              There are no open Gerrit changes