cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Spriegel (JIRA)" <>
Subject [jira] [Created] (CASSANDRA-6892) Cassandra 2.0.x validates Thrift columns incorrectly and causes InvalidRequestException
Date Thu, 20 Mar 2014 09:33:44 GMT
Christian Spriegel created CASSANDRA-6892:

             Summary: Cassandra 2.0.x validates Thrift columns incorrectly and causes InvalidRequestException
                 Key: CASSANDRA-6892
             Project: Cassandra
          Issue Type: Bug
          Components: Core
            Reporter: Christian Spriegel

I just upgrade my local dev machine to Cassandra 2.0, which causes one of my automated tests
to fail now. With the latest 1.2.x it was working fine.

The Exception I get on my client (using Hector) is:
me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:(Expected
8 or 0 byte long (21)) [MDS_0][MasterdataIndex][key2] failed validation)
	at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(
	at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(
	at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecuteOperation(
	at me.prettyprint.cassandra.model.MutatorImpl.execute(
	at me.prettyprint.cassandra.service.template.AbstractColumnFamilyTemplate.executeBatch(
	at me.prettyprint.cassandra.service.template.AbstractColumnFamilyTemplate.executeIfNotBatched(
	at me.prettyprint.cassandra.service.template.ColumnFamilyTemplate.update(
	at com.mycompany.spring3utils.dataaccess.cassandra.AbstractCassandraDAO.doUpdate(
Caused by: InvalidRequestException(why:(Expected 8 or 0 byte long (21)) [MDS_0][MasterdataIndex][key2]
failed validation)
	at org.apache.cassandra.thrift.Cassandra$
	at org.apache.thrift.TServiceClient.receiveBase(
	at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(
	at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(
	at me.prettyprint.cassandra.model.MutatorImpl$3.execute(
	at me.prettyprint.cassandra.model.MutatorImpl$3.execute(
	at me.prettyprint.cassandra.service.Operation.executeAndSetResult(
	at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(
	... 46 more

The schema of my column family is:
create column family MasterdataIndex with
    compression_options = {sstable_compression:SnappyCompressor, chunk_length_kb:64} and
    comparator = UTF8Type and
    key_validation_class = 'CompositeType(UTF8Type,LongType)' and
    default_validation_class = BytesType;

>From the error message it looks like Cassandra is trying to validate the value with the
key-validator! (My value in this case it 21 bytes long)

I studied the Cassandra 2.0 code and found something wrong. It seems in CFMetaData.addDefaultKeyAliases
it passes the KeyValidator into ColumnDefinition.partitionKeyDef. Inside ColumnDefinition
the validator is expected to be the value validator!

In CFMetaData:
    private List<ColumnDefinition> addDefaultKeyAliases(List<ColumnDefinition>
        for (int i = 0; i < pkCols.size(); i++)
            if (pkCols.get(i) == null)
                Integer idx = null;
                AbstractType<?> type = keyValidator;
                if (keyValidator instanceof CompositeType)
                    idx = i;
                    type = ((CompositeType)keyValidator).types.get(i);
                // For compatibility sake, we call the first alias 'key' rather than 'key1'.
                // is inconsistent with column alias, but it's probably not worth risking
breaking compatibility now.
                ByteBuffer name = ByteBufferUtil.bytes(i == 0 ? DEFAULT_KEY_ALIAS : DEFAULT_KEY_ALIAS
+ (i + 1));
                ColumnDefinition newDef = ColumnDefinition.partitionKeyDef(name, type, idx);
// type is LongType in my case, as it uses keyValidator !!!
                column_metadata.put(, newDef);
                pkCols.set(i, newDef);
        return pkCols;
    public AbstractType<?> getValidator() // in ThriftValidation this is expected to
be the value validator!
        return validator;

This message was sent by Atlassian JIRA

View raw message