mirror of https://github.com/apache/cassandra
merge from 0.5 branch
git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@889662 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0967566af3
commit
d4d8381daa
|
|
@ -1,5 +1,6 @@
|
||||||
0.5.0 RC1
|
0.5.0 RC1
|
||||||
* Fix potential NPE in get_range_slice (CASSANDRA-623)
|
* Fix potential NPE in get_range_slice (CASSANDRA-623)
|
||||||
|
* add CRC32 to commitlog entries (CASSANDRA-605)
|
||||||
|
|
||||||
|
|
||||||
0.5.0 beta 2
|
0.5.0 beta 2
|
||||||
|
|
|
||||||
1
NEWS.txt
1
NEWS.txt
|
|
@ -6,6 +6,7 @@
|
||||||
or simply remove the commitlog directory if you only have test data.
|
or simply remove the commitlog directory if you only have test data.
|
||||||
(If more writes come in after the flush command, starting 0.5 will error
|
(If more writes come in after the flush command, starting 0.5 will error
|
||||||
out; if that happens, just go back to 0.4 and flush again.)
|
out; if that happens, just go back to 0.4 and flush again.)
|
||||||
|
The format changed twice: from 0.4 to beta1, and from beta2 to RC1.
|
||||||
|
|
||||||
1. Bootstrap, move, load balancing, and active repair have been added.
|
1. Bootstrap, move, load balancing, and active repair have been added.
|
||||||
See http://wiki.apache.org/cassandra/Operations
|
See http://wiki.apache.org/cassandra/Operations
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.zip.Checksum;
|
||||||
|
import java.util.zip.CRC32;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
@ -305,11 +307,13 @@ public class CommitLog
|
||||||
if (logger_.isDebugEnabled())
|
if (logger_.isDebugEnabled())
|
||||||
logger_.debug("Reading mutation at " + reader.getFilePointer());
|
logger_.debug("Reading mutation at " + reader.getFilePointer());
|
||||||
|
|
||||||
|
long claimedCRC32;
|
||||||
byte[] bytes;
|
byte[] bytes;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bytes = new byte[(int) reader.readLong()]; // readlong can throw EOFException too
|
bytes = new byte[(int) reader.readLong()]; // readlong can throw EOFException too
|
||||||
reader.readFully(bytes);
|
reader.readFully(bytes);
|
||||||
|
claimedCRC32 = reader.readLong();
|
||||||
}
|
}
|
||||||
catch (EOFException e)
|
catch (EOFException e)
|
||||||
{
|
{
|
||||||
|
|
@ -317,8 +321,16 @@ public class CommitLog
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bufIn.reset(bytes, bytes.length);
|
bufIn.reset(bytes, bytes.length);
|
||||||
|
Checksum checksum = new CRC32();
|
||||||
|
checksum.update(bytes, 0, bytes.length);
|
||||||
|
if (claimedCRC32 != checksum.getValue())
|
||||||
|
{
|
||||||
|
// this part of the log must not have been fsynced. probably the rest is bad too,
|
||||||
|
// but just in case there is no harm in trying them.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* read the commit log entry */
|
/* deserialize the commit log entry */
|
||||||
final RowMutation rm = RowMutation.serializer().deserialize(bufIn);
|
final RowMutation rm = RowMutation.serializer().deserialize(bufIn);
|
||||||
if (logger_.isDebugEnabled())
|
if (logger_.isDebugEnabled())
|
||||||
logger_.debug(String.format("replaying mutation for %s.%s: %s",
|
logger_.debug(String.format("replaying mutation for %s.%s: %s",
|
||||||
|
|
@ -620,16 +632,16 @@ public class CommitLog
|
||||||
long currentPosition = -1L;
|
long currentPosition = -1L;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* serialize the row */
|
|
||||||
currentPosition = logWriter_.getFilePointer();
|
currentPosition = logWriter_.getFilePointer();
|
||||||
CommitLogContext cLogCtx = new CommitLogContext(logFile_, currentPosition);
|
CommitLogContext cLogCtx = new CommitLogContext(logFile_, currentPosition);
|
||||||
/* Update the header */
|
|
||||||
maybeUpdateHeader(rowMutation);
|
maybeUpdateHeader(rowMutation);
|
||||||
|
Checksum checkum = new CRC32();
|
||||||
if (serializedRow instanceof DataOutputBuffer)
|
if (serializedRow instanceof DataOutputBuffer)
|
||||||
{
|
{
|
||||||
DataOutputBuffer buffer = (DataOutputBuffer) serializedRow;
|
DataOutputBuffer buffer = (DataOutputBuffer) serializedRow;
|
||||||
logWriter_.writeLong(buffer.getLength());
|
logWriter_.writeLong(buffer.getLength());
|
||||||
logWriter_.write(buffer.getData(), 0, buffer.getLength());
|
logWriter_.write(buffer.getData(), 0, buffer.getLength());
|
||||||
|
checkum.update(buffer.getData(), 0, buffer.getLength());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -637,7 +649,9 @@ public class CommitLog
|
||||||
byte[] bytes = (byte[]) serializedRow;
|
byte[] bytes = (byte[]) serializedRow;
|
||||||
logWriter_.writeLong(bytes.length);
|
logWriter_.writeLong(bytes.length);
|
||||||
logWriter_.write(bytes);
|
logWriter_.write(bytes);
|
||||||
|
checkum.update(bytes, 0, bytes.length);
|
||||||
}
|
}
|
||||||
|
logWriter_.writeLong(checkum.getValue());
|
||||||
maybeRollLog();
|
maybeRollLog();
|
||||||
return cLogCtx;
|
return cLogCtx;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue