Skip to content

Commit

Permalink
ignore maxtimestamp unless it includes row tombstones correctly
Browse files Browse the repository at this point in the history
patch by jbellis; reviewed by yukim for CASSANDRA-4205
  • Loading branch information
jbellis committed May 3, 2012
1 parent abb39c2 commit c1148ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/java/org/apache/cassandra/io/sstable/Descriptor.java
Expand Up @@ -58,7 +58,8 @@ public class Descriptor
// h (1.0): tracks max client timestamp in metadata component
// hb (1.0.3): records compression ration in metadata component
// hc (1.0.4): records partitioner in metadata component
public static final String CURRENT_VERSION = "hc";
// hd (1.0.10): includes row tombstones in maxtimestamp
public static final String CURRENT_VERSION = "hd";

public final File directory;
/** version has the following format: <code>[a-z]+</code> */
Expand Down Expand Up @@ -103,7 +104,7 @@ public Descriptor(String version, File directory, String ksname, String cfname,
hasEncodedKeys = version.compareTo("e") < 0;
usesOldBloomFilter = version.compareTo("f") < 0;
metadataIncludesReplayPosition = version.compareTo("g") >= 0;
tracksMaxTimestamp = version.compareTo("h") >= 0;
tracksMaxTimestamp = version.compareTo("hd") >= 0;
hasCompressionRatio = version.compareTo("hb") >= 0;
hasPartitioner = version.compareTo("hc") >= 0;
isLatestVersion = version.compareTo(CURRENT_VERSION) == 0;
Expand Down Expand Up @@ -272,6 +273,16 @@ public boolean isStreamCompatible()
return isCompatible() && version.charAt(0) >= 'f';
}

/**
* Versions [h..hc] contained a timestamp value that was computed incorrectly, ignoring row tombstones.
* containsTimestamp returns true if there is a timestamp value in the metadata file; to know if it
* actually contains a *correct* timestamp, see tracksMaxTimestamp.
*/
public boolean containsTimestamp()
{
return version.compareTo("h") >= 0;
}

@Override
public String toString()
{
Expand Down
Expand Up @@ -206,7 +206,9 @@ public SSTableMetadata deserialize(DataInputStream dis, Descriptor desc) throws
ReplayPosition replayPosition = desc.metadataIncludesReplayPosition
? ReplayPosition.serializer.deserialize(dis)
: ReplayPosition.NONE;
long maxTimestamp = desc.tracksMaxTimestamp ? dis.readLong() : Long.MIN_VALUE;
long maxTimestamp = desc.containsTimestamp() ? dis.readLong() : Long.MIN_VALUE;
if (!desc.tracksMaxTimestamp) // see javadoc to Descriptor.containsTimestamp
maxTimestamp = Long.MIN_VALUE;
double compressionRatio = desc.hasCompressionRatio
? dis.readDouble()
: Double.MIN_VALUE;
Expand Down

0 comments on commit c1148ce

Please sign in to comment.