Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-10171

AbstractRedisData version being incremented for no-op operations can lead to delta not being applied on secondary

    XMLWordPrintableJSON

Details

    Description

      For SADD, which may or may not modify the data in the region depending on whether the member being added is already present in the set, the version in AbstractRedisData is updated regardless of whether a Delta is sent to the secondary. This can lead to the version on the primary wrapping around to be equal to the version on the secondary, which means that if a delta is sent, it will not be applied on the secondary, leading to potential data loss.

      Below is a test to show this behaviour:

      @Test
      public void deltaVersionOnPrimary_shouldNotUpdate_ifNoDeltaSent() {
        String originalMember = "fixedMemberName";
        String key = clusterStartUp.getKeyOnServer("tag", 1);
        
        // Version of primary = 0
        // Version of secondary = 0
        jedis.sadd(key, originalMember);
      
        // No changes are made to the set, since adding an already existing member doesn't modify it
        // Version of primary wraps around back to -1
        // Version of secondary doesn't change because we don't send a delta
        for (int i = 0; i < 255; ++i) {
          jedis.sadd(key, originalMember);
        }
      
        String newMember = "aNewMemberName";
        // Version of primary = 0
        // Version of secondary = 0, delta is not applied
        jedis.sadd(key, newMember);
      
        assertThat(jedis.smembers(key)).containsExactlyInAnyOrder(originalMember, newMember);
      
        clusterStartUp.crashVM(1); // kill primary server
      
        assertThat(jedis.smembers(key)).containsExactlyInAnyOrder(originalMember, newMember);
      } 

      The example here uses SADD, but potentially, any command that can be a no-op and uses a versioned Delta is at risk of hitting this. All commands should be checked to ensure they're not vulnerable to this bug.

      Attachments

        Activity

          People

            kris10 Kristen
            donalevans Donal Evans
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: