ignore replayposition in sstables that may not be generated by time-in-millis

patch by jbellis; reviewed by Fabien Rousseau for CASSANDRA-4782
This commit is contained in:
Jonathan Ellis 2012-10-11 08:49:50 -05:00
parent 46fc843bbd
commit 178c934aa1
4 changed files with 15 additions and 3 deletions

View File

@ -1,4 +1,5 @@
1.1.6
* fix commitlog replay for nanotime-infected sstables (CASSANDRA-4782)
* preflight check ttl for maximum of 20 years (CASSANDRA-4771)
* Fix HH to compact with correct gcBefore, which avoids wiping out
undelivered hints (CASSANDRA-4772)

View File

@ -14,8 +14,10 @@ by version X, but the inverse is not necessarily the case.)
Upgrading
---------
- Nothing specific to this release, but please see 1.1 if you are upgrading
from a previous version.
- If you are using counters, you should drain existing Cassandra nodes
prior to the upgrade to prevent overcount during commitlog replay
(see CASSANDRA-4782). For non-counter uses, drain is not required
but is a good practice to minimize restart time.
1.1.5

View File

@ -59,7 +59,8 @@ public class Descriptor
// hc (1.0.4): records partitioner in metadata component
// hd (1.0.10): includes row tombstones in maxtimestamp
// he (1.1.3): includes ancestors generation in metadata component
public static final String CURRENT_VERSION = "he";
// hf (1.1.6): marker that replay position corresponds to 1.1.5+ millis-based id (see CASSANDRA-4782)
public static final String CURRENT_VERSION = "hf";
public final File directory;
/** version has the following format: <code>[a-z]+</code> */
@ -76,6 +77,7 @@ public class Descriptor
public final boolean isLatestVersion;
public final boolean usesOldBloomFilter;
public final boolean metadataIncludesReplayPosition;
public final boolean metadataIncludesModernReplayPosition;
public final boolean tracksMaxTimestamp;
public final boolean hasCompressionRatio;
public final boolean hasPartitioner;
@ -109,6 +111,7 @@ public class Descriptor
hasCompressionRatio = version.compareTo("hb") >= 0;
hasPartitioner = version.compareTo("hc") >= 0;
hasAncestors = version.compareTo("he") >= 0;
metadataIncludesModernReplayPosition = version.compareTo("hf") >= 0;
isLatestVersion = version.compareTo(CURRENT_VERSION) == 0;
}

View File

@ -217,6 +217,12 @@ public class SSTableMetadata
ReplayPosition replayPosition = desc.metadataIncludesReplayPosition
? ReplayPosition.serializer.deserialize(dis)
: ReplayPosition.NONE;
if (!desc.metadataIncludesModernReplayPosition)
{
// replay position may be "from the future" thanks to older versions generating them with nanotime.
// make sure we don't omit replaying something that we should. see CASSANDRA-4782
replayPosition = ReplayPosition.NONE;
}
long maxTimestamp = desc.containsTimestamp() ? dis.readLong() : Long.MIN_VALUE;
if (!desc.tracksMaxTimestamp) // see javadoc to Descriptor.containsTimestamp
maxTimestamp = Long.MIN_VALUE;