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.


        No work has yet been logged on this issue.


          • 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