mirror of https://github.com/apache/cassandra
Use the correct digest file and reload sstable metadata in nodetool verify
Patch by marcuse; reviewed by Ariel Weisberg for CASSANDRA-14217
This commit is contained in:
parent
40148a178b
commit
21978bf9bb
|
|
@ -1,4 +1,5 @@
|
|||
3.0.16
|
||||
* Use the correct digest file and reload sstable metadata in nodetool verify (CASSANDRA-14217)
|
||||
* Handle failure when mutating repaired status in Verifier (CASSANDRA-13933)
|
||||
* Close socket on error during connect on OutboundTcpConnection (CASSANDRA-9630)
|
||||
* Set encoding for javadoc generation (CASSANDRA-14154)
|
||||
|
|
|
|||
|
|
@ -259,6 +259,8 @@ public class Verifier implements Closeable
|
|||
try
|
||||
{
|
||||
sstable.descriptor.getMetadataSerializer().mutateRepairedAt(sstable.descriptor, ActiveRepairService.UNREPAIRED_SSTABLE);
|
||||
sstable.reloadSSTableMetadata();
|
||||
cfs.getTracker().notifySSTableRepairedStatusChanged(Collections.singleton(sstable));
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class DataIntegrityMetadata
|
|||
{
|
||||
this.descriptor = descriptor;
|
||||
checksum = descriptor.version.uncompressedChecksumType().newInstance();
|
||||
digestReader = RandomAccessReader.open(new File(descriptor.filenameFor(Component.digestFor(descriptor.version.uncompressedChecksumType()))));
|
||||
digestReader = RandomAccessReader.open(new File(descriptor.filenameFor(descriptor.digestComponent)));
|
||||
dataReader = RandomAccessReader.open(new File(descriptor.filenameFor(Component.DATA)));
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
|||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.UpdateBuilder;
|
||||
import org.apache.cassandra.db.compaction.AbstractCompactionStrategy;
|
||||
import org.apache.cassandra.db.compaction.CompactionManager;
|
||||
import org.apache.cassandra.db.compaction.Verifier;
|
||||
import org.apache.cassandra.db.marshal.UUIDType;
|
||||
|
|
@ -44,9 +45,14 @@ 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.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
|
|
@ -368,6 +374,39 @@ public class VerifyTest
|
|||
}
|
||||
}
|
||||
|
||||
@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.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"))
|
||||
{
|
||||
correctChecksum = Long.parseLong(file.readLine());
|
||||
}
|
||||
writeChecksum(++correctChecksum, sstable.descriptor.filenameFor(sstable.descriptor.digestComponent));
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import org.apache.cassandra.cql3.QueryProcessor;
|
|||
import org.apache.cassandra.cql3.UntypedResultSet;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
import org.apache.cassandra.db.compaction.Verifier;
|
||||
import org.apache.cassandra.dht.IPartitioner;
|
||||
import org.apache.cassandra.dht.Range;
|
||||
import org.apache.cassandra.dht.Token;
|
||||
|
|
@ -186,6 +187,23 @@ public class LegacySSTableTest
|
|||
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++)
|
||||
|
|
|
|||
Loading…
Reference in New Issue