Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-358

Sort nodes so that changes in order from server config do not create a different hashcode

    XMLWordPrintable

Details

    • Task
    • Resolution: Fixed
    • Major
    • 1.3.2
    • 1.3.1
    • library
    • None

    Description

      Hi Jeff,

      Found that you are the leader of the GitHub project couchbase-net-client, we’ve encountered an issue with it and made patch. But not sure where is the community forum anymore. So hope you don’t mind me directly emailing you from your GitHub profile.

      Anyway, we noticed that with 1.3.1 version of the Couchbase .Net client, we are frequently (every few seconds) getting the following log message.

      2014-01-09 00:03:03,344 [cbp_thread] INFO Couchbase.CouchbasePool Received new configuration.

      Even though our Couchbase cluster config has not changed. Comparing the information, it looks like the pool config returned by Couchbase, especially the “nodes’ field, the order or the nodes are not the same between calls.

      Going through the code in the “ClusterConfig” class, it uses GetHashCode to compare if the pool config has changed, and it seems to be order sensitive for the “nodes” field.

      So if I change it to sort the “nodes” before generating the HashCode, does it sounds like a suitable fix? I’m not to familiar with the internal of Couchbase, so not sure will it break something else.

      public override int GetHashCode()
      {
      var cnehc = new Enyim.HashCodeCombiner();

      • for (var i = 0; i < nodes.Length; i++)
      • cnehc.Add(nodes[i].GetHashCode());
        + var sortedNodes = nodes.OrderBy(n => n.HostName);
        + foreach (var node in sortedNodes)
        + cnehc.Add(node.GetHashCode());

      if (vBucketForwardServerMap != null)
      cnehc.Add(vBucketForwardServerMap.GetHashCode());

      Would be helpful if you can point me to the right place to ask this question.

      Kind Regards,

      Eddie

      Attachments

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

        Activity

          People

            jmorris Jeff Morris
            jmorris Jeff Morris
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty