Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-18546

Remove unnecessary shuffling of GossipDigests in Gossiper#makeRandomGossipDigest

    XMLWordPrintableJSON

Details

    Description

      In going through trying to understand the Gossiper code I come across:

          /**
           * The gossip digest is built based on randomization
           * rather than just looping through the collection of live endpoints.
           *
           * @param gDigests list of Gossip Digests.
           */
          private void makeRandomGossipDigest(List<GossipDigest> gDigests) 

      But I couldn't see what purpose randomization had. In fact in 3.11 it will call:

       doSort(gDigestList); 

      On the receiving end, negating the purpose of the randomization.

       

      In discussion with stefan.miklosovic he found this ticket CASSANDRA-14174

      So it seems to me this randomization may have been to allow for limited sizes of SYN messages. But this feature doesn't exist and as such by randomizing it is:

      • creating more garbage
      • using more CPU (sure its mostly trival; see next point)
      • more time spent on unnecessary functionality on the single threaded gossip stage.
      • complicating the code and making it more difficult to understand

      In fact there is a bug in the implementation:

              int generation = 0;
              int maxVersion = 0;        // local epstate will be part of endpointStateMap
              List<InetAddress> endpoints = new ArrayList<InetAddress>(endpointStateMap.keySet());
              Collections.shuffle(endpoints, random);
              for (InetAddress endpoint : endpoints)
              {
                  epState = endpointStateMap.get(endpoint);
                  if (epState != null)
                  {
                      generation = epState.getHeartBeatState().getGeneration();
                      maxVersion = getMaxEndpointStateVersion(epState);
                  }
                  gDigests.add(new GossipDigest(endpoint, generation, maxVersion));
              } 

      If epState is null and we already had a non-null epState, then the next digest will use the generation and maxVersion of the previous iterated epState.

       

      Here is change to remove this randomization and fix the above bug, https://github.com/apache/cassandra/pull/2357/commits/1ba422ab5de35f7057c7621ec3607dcbca19768c

      Attachments

        Issue Links

          Activity

            People

              smiklosovic Stefan Miklosovic
              cam1982 Cameron Zemek
              Stefan Miklosovic
              Brandon Williams
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m