4 Replies Latest reply on Jun 27, 2011 9:51 AM by mircea.markus

    TopologyAwareConsistentHash / numOwners=1

    shane_dev

      It turns out that the TopologyAwareConsistentHash does not work properly when numOwners is set to 1.

       

      I fully appreciate that this wheel is designed specifically for server hinting when you are maintaining backups, but I thought it was worth noting in case anyone else comes across the problem.

       

      Specifically, the problem is with getStateProvidersOnLeave.

       

      1. Assume you have nodes 1, 2, and 4.
      2. Now node 3 joins.
      3. This method will iterate over each address and will skip the joiner (node3).
      4. For the remaining nodes it will call getOwners
        • e.g. - getOwners(node1), getOwners(node2), getOwners(node3)
      5. This method will always begin by adding the first node in the tailMap which is the address that is being iterated over. Since numOwners is set to 1 it skips the while loop and returns the result.
      6. So...
        • getOwners(1) returns {node1}
        • getOwners(2) returns {node2}
        • getOwners(4) returns {node4}
      7. Now we return to getStateProvidersOnLeave
      8. It now checks to see if the result contains the joiner (node3). However, it can never contain the joiner.

       

      On one hand, it would be nice if this topology worked even when numOwners is set to 1. On the other, it is an unusual use case and perhaps a note in the documentation would suffice. In our case, we were setting the machineId premptively as we were planning to move to maintaining backups at some point later on.