InvalidRequestException(why:Too many bytes for comparator) on execute query to composite columns using Asytanax

StackOverflow https://stackoverflow.com/questions/12360067

  •  01-07-2021
  •  | 
  •  

Question

I'm trying to fetch out of composite columns using Astyanax 1.0.9 and got "InvalidRequestException(why:Too many bytes for comparator)"

Here is my CF:

CREATE TABLE user_attributes (
user_id bigint,
attr_name ascii,
attr_value text,
last_sync_timestamp bigint,
last_sync_digest text,
PRIMARY KEY (user_id, attr_name)
);

I can read data out with CQL:

select * from user_attributes where user_id = 1 and attr_name = 'mock';

Here is my POJO for composite column:

public static class UserAttributeCassandraTuple implements Comparable {
    public @Component(ordinal = 0) String attrName;
    public @Component(ordinal = 1) String attrValue;
    public @Component(ordinal = 2) long lastSyncTimeStamp;
    public @Component(ordinal = 3) String lastSyncDigest;

    public int compareTo(Object o) { /* impl omitted here */ }
    public int hashCode() { /* impl omitted here */ }
    public boolean equals(Object o) { /* impl omitted here */ }
}

Here is my test driver: (keyspace is setup in junit @before and works fine for non-composite columns)

@Test
public void test_user_attributes() throws Exception {

    ColumnFamily<BigInteger, UserAttributeCassandraTuple> CF_USER_ATTR = new ColumnFamily<BigInteger, UserAttributeCassandraTuple>(
        "user_attributes", // Column Family Name
        BigIntegerSerializer.get(), // Key Serializer
        userAttributeSerializer); // Column Serializer

    // proto column for "mock"
    UserAttributeCassandraTuple mockColumn = new UserAttributeCassandraTuple();
    mockColumn.attrName = "mock";

    OperationResult<ColumnList<UserAttributeCassandraTuple>> result = keyspace.prepareQuery(CF_USER_ATTR)
    .getKey(BigInteger.valueOf(1))
    .withColumnSlice(mockColumn, mockColumn)
    .execute();
    ColumnList<UserAttributeCassandraTuple> columns = result.getResult();

    for (Column<UserAttributeCassandraTuple> c : columns) {
        System.out.println(c.getName() + "=" + c.getStringValue());
    }
}

It compiles fine, but failed during execute():

com.netflix.astyanax.connectionpool.exceptions.BadRequestException: BadRequestException: [host=127.0.0.1(127.0.0.1):9160, latency=22(44), attempts=1] InvalidRequestException(why:Too many bytes for comparator)
at com.netflix.astyanax.thrift.ThriftConverter.ToConnectionPoolException(ThriftConverter.java:159)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:60)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1$2.execute(ThriftColumnFamilyQueryImpl.java:196)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1$2.execute(ThriftColumnFamilyQueryImpl.java:188)
at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$1.execute(ThriftSyncConnectionFactoryImpl.java:132)
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:52)
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:229)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1.execute(ThriftColumnFamilyQueryImpl.java:186)
at com.ebay.raptor.search.test.srp.domain.cassandra.CassandraTest.test_user_attributes(CassandraTest.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: InvalidRequestException(why:Too many bytes for comparator)
at org.apache.cassandra.thrift.Cassandra$get_slice_result.read(Cassandra.java:7196)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_get_slice(Cassandra.java:543)
at org.apache.cassandra.thrift.Cassandra$Client.get_slice(Cassandra.java:527)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1$2.internalExecute(ThriftColumnFamilyQueryImpl.java:201)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1$2.internalExecute(ThriftColumnFamilyQueryImpl.java:188)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:55)
... 30 more

I tried replacing BigInteger with Long, but got the same error.

Any suggestion what I am doing wrong?

thanks Chuck

Was it helpful?

Solution

Astyanax is a Thrift-based client, so this isn't going to work: the (server-side) Thrift validation path is not CQL-aware.

We are addressing this in 1.2.0 for a smoother upgrade path; otherwise, you either need to use a CQL client to access your CQL tables, or define your schema using the CLI for a Thrift-based client.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top