Updated Branches: refs/heads/cassandra-1.2 9be437bd7 -> 3575fdccb
Improve error message when loaded sstable doesn't match schema patch by slebresne; reviewed by driftx for CASSANDRA-6262 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/d3872408 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/d3872408 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/d3872408 Branch: refs/heads/cassandra-1.2 Commit: d3872408d22ae208a5cb9cdf4c1d76370510459d Parents: 5f63578 Author: Sylvain Lebresne <sylv...@datastax.com> Authored: Sun Jan 19 19:24:06 2014 -0800 Committer: Sylvain Lebresne <sylv...@datastax.com> Committed: Sun Jan 19 19:24:06 2014 -0800 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/db/marshal/CompositeType.java | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/d3872408/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 25c105c..8626b64 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,6 +10,7 @@ * Add ability to throttle batchlog replay (CASSANDRA-6550) * Fix executing LOCAL_QUORUM with SimpleStrategy (CASSANDRA-6545) * Avoid StackOverflow when using large IN queries (CASSANDRA-6567) + * Improve error message when schema doesn't match loaded sstable (CASSANDRA-6262) 1.2.13 http://git-wip-us.apache.org/repos/asf/cassandra/blob/d3872408/src/java/org/apache/cassandra/db/marshal/CompositeType.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/marshal/CompositeType.java b/src/java/org/apache/cassandra/db/marshal/CompositeType.java index 8cb1e34..138a065 100644 --- a/src/java/org/apache/cassandra/db/marshal/CompositeType.java +++ b/src/java/org/apache/cassandra/db/marshal/CompositeType.java @@ -86,12 +86,25 @@ public class CompositeType extends AbstractCompositeType protected AbstractType<?> getComparator(int i, ByteBuffer bb) { - return types.get(i); + try + { + return types.get(i); + } + catch (IndexOutOfBoundsException e) + { + // We shouldn't get there in general because 1) we shouldn't construct broken composites + // from CQL and 2) broken composites coming from thrift should be rejected by validate. + // There is a few cases however where, if the schema has changed since we created/validated + // the composite, this will be thrown (see #6262). Those cases are a user error but + // throwing a more meaningful error message to make understanding such error easier. . + throw new RuntimeException("Cannot get comparator " + i + " in " + this + ". " + + "This might due to a mismatch between the schema and the data read", e); + } } protected AbstractType<?> getComparator(int i, ByteBuffer bb1, ByteBuffer bb2) { - return types.get(i); + return getComparator(i, bb1); } protected AbstractType<?> getAndAppendComparator(int i, ByteBuffer bb, StringBuilder sb)