Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-51612

Get cluster config fails in mixed mode on upgraded node >= 7.0.2

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Yes
    • KV March-22

    Description

      To reproduce

      • Setup 6.6.5 node
      • Rebalance in >= 7.0.2 node
      • Bootstrap memcached connection and try to get cluster config from the upgraded node
      • The get fails with status 1 (key not found)

      from mc_bin_client import MemcachedClient
      client = MemcachedClient("127.0.0.1", 12000)
      client.hello("")
      client.sasl_auth_plain("Administrator", "password")
      client.bucket_select("default")
      _, _, config = client._doCmd(0xb5, '', '')
      

       
      This issue was introduced in 7.0.2 when introducing MB-46363

      The issue is that ns_server sends a -1 epoch when cluster compat is < 7.0. When kv_engine handles the get cluster config here, maybeGetConfiguration checks if the passed in version is less than the active version here. If so, it returns a config. It was assumed that supplying 0s for this arg would always return true however the introduction of -1 broke this assumption.
      This code compares the actual epoch (-1) with the default epoch (0) and 0 is not less than -1 so no config is returned which ultimately returns an empty unique_ptr which fails the if branch here and returns KeyEnoent

      This diff fixed the issue for me although the fix probably needs to be more robust

      diff --git a/daemon/cluster_config.h b/daemon/cluster_config.h
      index 8b0cf70bb..d8cd302a7 100644
      --- a/daemon/cluster_config.h
      +++ b/daemon/cluster_config.h
      @@ -27,14 +27,14 @@ public:
               : epoch(epoch), revno(revno){};
       
           bool operator==(const ClustermapVersion& other) const {
      -        return epoch == other.epoch && revno == other.revno;
      +        return (other.epoch == -1 || epoch == other.epoch) && revno == other.revno;
           }
       
           bool operator<(const ClustermapVersion& other) const {
               if (epoch < other.epoch) {
                   return true;
               }
      -        if (epoch == other.epoch) {
      +        if (other.epoch == -1 || epoch == other.epoch) {
                   return revno < other.revno;
               }
               return false;
      

      Attachments

        Issue Links

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

          Activity

            People

              jake.rawsthorne Jake Rawsthorne
              jake.rawsthorne Jake Rawsthorne
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty