Merge branch 'cassandra-3.11' into trunk

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/161c37da
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/161c37da
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/161c37da

Branch: refs/heads/trunk
Commit: 161c37da8fa93f572e3c9474cb37fc6d96058ff6
Parents: a4cf29f 6eb65e5
Author: Marcus Eriksson <marc...@apache.org>
Authored: Fri Feb 9 16:26:24 2018 +0100
Committer: Marcus Eriksson <marc...@apache.org>
Committed: Fri Feb 9 16:26:24 2018 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/db/compaction/Verifier.java       |  2 ++
 .../org/apache/cassandra/db/VerifyTest.java     | 38 ++++++++++++++++++++
 .../cassandra/io/sstable/LegacySSTableTest.java | 18 ++++++++++
 4 files changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/161c37da/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index e860265,c38b69b..0f7b7fe
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -207,7 -19,9 +207,8 @@@
   * Round buffer size to powers of 2 for the chunk cache (CASSANDRA-13897)
   * Update jackson JSON jars (CASSANDRA-13949)
   * Avoid locks when checking LCS fanout and if we should defrag 
(CASSANDRA-13930)
 - * Correctly count range tombstones in traces and tombstone thresholds 
(CASSANDRA-8527)
  Merged from 3.0:
+  * Use the correct digest file and reload sstable metadata in nodetool verify 
(CASSANDRA-14217)
   * Handle failure when mutating repaired status in Verifier (CASSANDRA-13933)
   * Set encoding for javadoc generation (CASSANDRA-14154)
   * Fix index target computation for dense composite tables with dropped 
compact storage (CASSANDRA-14104)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/161c37da/src/java/org/apache/cassandra/db/compaction/Verifier.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/compaction/Verifier.java
index 5a2a828,f0309b7..01e465e
--- a/src/java/org/apache/cassandra/db/compaction/Verifier.java
+++ b/src/java/org/apache/cassandra/db/compaction/Verifier.java
@@@ -259,7 -259,9 +259,9 @@@ public class Verifier implements Closea
          {
              try
              {
 -                
sstable.descriptor.getMetadataSerializer().mutateRepairedAt(sstable.descriptor, 
ActiveRepairService.UNREPAIRED_SSTABLE);
 +                
sstable.descriptor.getMetadataSerializer().mutateRepaired(sstable.descriptor, 
ActiveRepairService.UNREPAIRED_SSTABLE, 
sstable.getSSTableMetadata().pendingRepair);
+                 sstable.reloadSSTableMetadata();
+                 
cfs.getTracker().notifySSTableRepairedStatusChanged(Collections.singleton(sstable));
              }
              catch(IOException ioe)
              {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/161c37da/test/unit/org/apache/cassandra/db/VerifyTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/VerifyTest.java
index 2eb741c,a332f74..8b9b437
--- a/test/unit/org/apache/cassandra/db/VerifyTest.java
+++ b/test/unit/org/apache/cassandra/db/VerifyTest.java
@@@ -44,13 -46,14 +45,17 @@@ import org.junit.runner.RunWith
  
  import java.io.*;
  import java.nio.file.Files;
+ import java.util.Collections;
 -import java.util.List;
+ import java.util.concurrent.ExecutionException;
  import java.util.zip.CRC32;
  import java.util.zip.CheckedInputStream;
  
 +import static org.apache.cassandra.SchemaLoader.counterCFMD;
 +import static org.apache.cassandra.SchemaLoader.createKeyspace;
 +import static org.apache.cassandra.SchemaLoader.loadSchema;
 +import static org.apache.cassandra.SchemaLoader.standardCFMD;
+ import static org.junit.Assert.assertFalse;
+ import static org.junit.Assert.assertTrue;
  import static org.junit.Assert.fail;
  
  @RunWith(OrderedJUnit4ClassRunner.class)
@@@ -375,6 -378,39 +380,39 @@@ public class VerifyTes
          }
      }
  
+     @Test
+     public void testMutateRepair() throws IOException, ExecutionException, 
InterruptedException
+     {
+         CompactionManager.instance.disableAutoCompaction();
+         Keyspace keyspace = Keyspace.open(KEYSPACE);
+         ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CORRUPT_CF2);
+ 
+         fillCF(cfs, 2);
+ 
+         SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
 -        
sstable.descriptor.getMetadataSerializer().mutateRepairedAt(sstable.descriptor, 
1);
++        
sstable.descriptor.getMetadataSerializer().mutateRepaired(sstable.descriptor, 
1, sstable.getSSTableMetadata().pendingRepair);
+         sstable.reloadSSTableMetadata();
+         
cfs.getTracker().notifySSTableRepairedStatusChanged(Collections.singleton(sstable));
+         assertTrue(sstable.isRepaired());
+         cfs.forceMajorCompaction();
+ 
+         sstable = cfs.getLiveSSTables().iterator().next();
+         Long correctChecksum;
 -        try (RandomAccessFile file = new 
RandomAccessFile(sstable.descriptor.filenameFor(sstable.descriptor.digestComponent),
 "rw"))
++        try (RandomAccessFile file = new 
RandomAccessFile(sstable.descriptor.filenameFor(Component.DIGEST), "rw"))
+         {
+             correctChecksum = Long.parseLong(file.readLine());
+         }
 -        writeChecksum(++correctChecksum, 
sstable.descriptor.filenameFor(sstable.descriptor.digestComponent));
++        writeChecksum(++correctChecksum, 
sstable.descriptor.filenameFor(Component.DIGEST));
+         try (Verifier verifier = new Verifier(cfs, sstable, false))
+         {
+             verifier.verify(false);
+             fail("should be corrupt");
+         }
+         catch (CorruptSSTableException e)
+         {}
+         assertFalse(sstable.isRepaired());
+     }
+ 
  
      protected void fillCF(ColumnFamilyStore cfs, int partitionsPerSSTable)
      {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/161c37da/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
index 8fc69bf,478327d..f669cd7
--- a/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
@@@ -193,19 -167,78 +194,36 @@@ public class LegacySSTableTes
              verifyReads(legacyVersion);
          }
      }
 -    @Test
 -    public void testReverseIterationOfLegacyIndexedSSTable() throws Exception
 -    {
 -        // During upgrades from 2.1 to 3.0, reverse queries can drop rows 
before upgradesstables is completed
 -        QueryProcessor.executeInternal("CREATE TABLE 
legacy_tables.legacy_ka_indexed (" +
 -                                       "  p int," +
 -                                       "  c int," +
 -                                       "  v1 int," +
 -                                       "  v2 int," +
 -                                       "  PRIMARY KEY(p, c)" +
 -                                       ")");
 -        loadLegacyTable("legacy_%s_indexed%s", "ka", "");
 -        UntypedResultSet rs = QueryProcessor.executeInternal("SELECT * " +
 -                                                             "FROM 
legacy_tables.legacy_ka_indexed " +
 -                                                             "WHERE p=1 " +
 -                                                             "ORDER BY c 
DESC");
 -        Assert.assertEquals(5000, rs.size());
 -    }
 -
 -    @Test
 -    public void testReadingLegacyIndexedSSTableWithStaticColumns() throws 
Exception
 -    {
 -        // During upgrades from 2.1 to 3.0, reading from tables with static 
columns errors before upgradesstables
 -        // is completed
 -        QueryProcessor.executeInternal("CREATE TABLE 
legacy_tables.legacy_ka_indexed_static (" +
 -                                       "  p int," +
 -                                       "  c int," +
 -                                       "  v1 int," +
 -                                       "  v2 int," +
 -                                       "  s1 int static," +
 -                                       "  s2 int static," +
 -                                       "  PRIMARY KEY(p, c)" +
 -                                       ")");
 -        loadLegacyTable("legacy_%s_indexed_static%s", "ka", "");
 -        UntypedResultSet rs = QueryProcessor.executeInternal("SELECT * " +
 -                                                             "FROM 
legacy_tables.legacy_ka_indexed_static " +
 -                                                             "WHERE p=1 ");
 -        Assert.assertEquals(5000, rs.size());
 -    }
  
+     @Test
+     public void verifyOldSSTables() throws Exception
+     {
+         for (String legacyVersion : legacyVersions)
+         {
+             loadLegacyTables(legacyVersion);
+             ColumnFamilyStore cfs = 
Keyspace.open("legacy_tables").getColumnFamilyStore(String.format("legacy_%s_simple",
 legacyVersion));
+             for (SSTableReader sstable : cfs.getLiveSSTables())
+             {
+                 try (Verifier verifier = new Verifier(cfs, sstable, false))
+                 {
+                     verifier.verify(true);
+                 }
+             }
+         }
+     }
+ 
      private void streamLegacyTables(String legacyVersion) throws Exception
      {
 -        for (int compact = 0; compact <= 1; compact++)
 -        {
 -            logger.info("Streaming legacy version {}{}", legacyVersion, 
getCompactNameSuffix(compact));
 -            streamLegacyTable("legacy_%s_simple%s", legacyVersion, 
getCompactNameSuffix(compact));
 -            streamLegacyTable("legacy_%s_simple_counter%s", legacyVersion, 
getCompactNameSuffix(compact));
 -            streamLegacyTable("legacy_%s_clust%s", legacyVersion, 
getCompactNameSuffix(compact));
 -            streamLegacyTable("legacy_%s_clust_counter%s", legacyVersion, 
getCompactNameSuffix(compact));
 -        }
 +            logger.info("Streaming legacy version {}", legacyVersion);
 +            streamLegacyTable("legacy_%s_simple", legacyVersion);
 +            streamLegacyTable("legacy_%s_simple_counter", legacyVersion);
 +            streamLegacyTable("legacy_%s_clust", legacyVersion);
 +            streamLegacyTable("legacy_%s_clust_counter", legacyVersion);
      }
  
 -    private void streamLegacyTable(String tablePattern, String legacyVersion, 
String compactNameSuffix) throws Exception
 +    private void streamLegacyTable(String tablePattern, String legacyVersion) 
throws Exception
      {
 -        String table = String.format(tablePattern, legacyVersion, 
compactNameSuffix);
 +        String table = String.format(tablePattern, legacyVersion);
          SSTableReader sstable = 
SSTableReader.open(getDescriptor(legacyVersion, table));
          IPartitioner p = sstable.getPartitioner();
          List<Range<Token>> ranges = new ArrayList<>();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to