Hi Jonathan
I could reproduce this on the Super1 super column family that comes
pre-packaged in cassandra's config file.
Here is the small program I wrote:
public class TestCassandra {
public static void main(String[] args)
{
try {
TestCassandra cassandra = new TestCassandra();
cassandra.set("key1", "val1".getBytes());
byte[] val = cassandra.get("key1");
assert(new String(val).equals("val1"));
cassandra.remove("key1");
val = cassandra.get("key1");
assert(val == null);
}catch(Exception e) {
e.printStackTrace();
}
}
public void set(String key, byte[] value) throws Exception {
TTransport tr = null;
try {
tr = new TSocket("192.168.1.83", 9160);
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
client.insert("Keyspace1", key, new ColumnPath("Super1",
key.getBytes("UTF-8"), "col1".getBytes("UTF-8")),
value, System.currentTimeMillis(),
ConsistencyLevel.ONE);
} catch(Exception e) {
throw e;
} finally {
if(tr != null)
tr.close();
}
}
public byte[] get(String key) throws Exception {
TTransport tr = null;
try {
tr = new TSocket("192.168.1.83", 9160);
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
SlicePredicate predicate = new SlicePredicate(null, new
SliceRange(new byte[0], new byte[0], false, 3));
ColumnParent parent = new ColumnParent("Super1",
key.getBytes("UTF-8"));
List<ColumnOrSuperColumn> results =
client.get_slice("Keyspace1", key, parent, predicate,
ConsistencyLevel.ONE);
byte[] colvalue = null;
for(ColumnOrSuperColumn col: results) {
Column currentColumn = col.getColumn();
String colName = new String(currentColumn.getName());
if(colName.equals("col1")) {
colvalue = currentColumn.getValue();
}
}
return colvalue;
} catch(Exception e) {
throw e;
} finally {
if(tr != null)
tr.close();
}
}
public void remove(String key) throws Exception {
TTransport tr = null;
try {
tr = new TSocket("192.168.1.83", 9160);
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
client.remove("Keyspace1", key,new ColumnPath("Super1",
null, null), System.currentTimeMillis(),ConsistencyLevel.ONE);
} catch (Exception e) {
throw e;
} finally {
if(tr != null)
tr.close();
}
}
}
On Thu, Oct 8, 2009 at 7:45 PM, Jonathan Ellis <[email protected]> wrote:
> Good. Should be easy to fix then. :) Can you post a program that
> reproduces this against the demo config?
>
> thanks,
>
> -Jonathan
>
> On Thu, Oct 8, 2009 at 8:45 PM, Ramzi Rabah <[email protected]> wrote:
>> Yeah I wiped out my commitLog files and data files and restarted the
>> server, and I still ran into this problem.
>>
>> Thanks
>> Ray
>>
>> On Thu, Oct 8, 2009 at 6:37 PM, Jonathan Ellis <[email protected]> wrote:
>>> Yes, that's a bug all right.
>>>
>>> Is this reproducible when you start with an empty database?
>>>
>>> On Thu, Oct 8, 2009 at 7:53 PM, Ramzi Rabah <[email protected]> wrote:
>>>> Hi Jonathan thanks a lot for the quick response :) here is the error
>>>> in the server log
>>>>
>>>> DEBUG [pool-1-thread-4] 2009-10-08 20:24:17,428 StorageProxy.java
>>>> (line 515) weakreadlocal reading
>>>> SliceFromReadCommand(table='Keyspace1', key='user1',
>>>> column_parent='QueryPath(columnFamilyName='Datastore',
>>>> superColumnName='[...@1a5e65f', columnName='null')', start='',
>>>> finish='', reversed=false, count=3)
>>>> ERROR [pool-1-thread-4] 2009-10-08 20:24:17,430 Cassandra.java (line
>>>> 657) Internal error processing get_slice
>>>> java.lang.AssertionError
>>>> at
>>>> org.apache.cassandra.db.ColumnFamilyStore.getColumnFamily(ColumnFamilyStore.java:1347)
>>>> at
>>>> org.apache.cassandra.db.ColumnFamilyStore.getColumnFamily(ColumnFamilyStore.java:1325)
>>>> at org.apache.cassandra.db.Table.getRow(Table.java:590)
>>>> at
>>>> org.apache.cassandra.db.SliceFromReadCommand.getRow(SliceFromReadCommand.java:59)
>>>> at
>>>> org.apache.cassandra.service.StorageProxy.weakReadLocal(StorageProxy.java:518)
>>>> at
>>>> org.apache.cassandra.service.StorageProxy.readProtocol(StorageProxy.java:310)
>>>> at
>>>> org.apache.cassandra.service.CassandraServer.readColumnFamily(CassandraServer.java:99)
>>>> at
>>>> org.apache.cassandra.service.CassandraServer.getSlice(CassandraServer.java:180)
>>>> at
>>>> org.apache.cassandra.service.CassandraServer.multigetSliceInternal(CassandraServer.java:249)
>>>> at
>>>> org.apache.cassandra.service.CassandraServer.get_slice(CassandraServer.java:218)
>>>> at
>>>> org.apache.cassandra.service.Cassandra$Processor$get_slice.process(Cassandra.java:651)
>>>> at
>>>> org.apache.cassandra.service.Cassandra$Processor.process(Cassandra.java:609)
>>>> at
>>>> org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:253)
>>>> at
>>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
>>>> at
>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
>>>> at java.lang.Thread.run(Thread.java:636)
>>>>
>>>> On Thu, Oct 8, 2009 at 5:41 PM, Jonathan Ellis <[email protected]> wrote:
>>>>> "Internal error" usually means you found a bug. Are there any
>>>>> exceptions in the server log?
>>>>>
>>>>> On Thu, Oct 8, 2009 at 7:33 PM, Ramzi Rabah <[email protected]> wrote:
>>>>>> Hello all,
>>>>>>
>>>>>> I am trying to test Cassandra for deploying it in production in our
>>>>>> company, and I am very pleased with the performance of the
>>>>>> reads/writes on Columns. I did run into an issue with the API though
>>>>>> while trying to play with supercolumns. Here is my code:
>>>>>>
>>>>>> // Creating a supercolumn with name = "key" and columns ("value",
>>>>>> "created").
>>>>>> long now = System.currentTimeMillis();
>>>>>> byte[] keyAsBytes = key.getBytes();
>>>>>>
>>>>>> ColumnOrSuperColumn colOrSuperCol = new ColumnOrSuperColumn();
>>>>>> SuperColumn superCol = new SuperColumn();
>>>>>> colOrSuperCol.setSuper_column(superCol);
>>>>>> superCol.setName(keyAsBytes);
>>>>>> List<Column> cols = new ArrayList<Column>();
>>>>>>
>>>>>> // first the key/value pair
>>>>>> Column col = new Column();
>>>>>> col.setName("value".getBytes());
>>>>>> col.setValue(value);
>>>>>> cols.add(col);
>>>>>>
>>>>>> // then the time created
>>>>>> col = new Column();
>>>>>> col.setName("created".getBytes());
>>>>>> col.setValue((now + "").getBytes());
>>>>>> cols.add(col);
>>>>>>
>>>>>> superCol.setColumns(cols);
>>>>>>
>>>>>> Map<String, List<ColumnOrSuperColumn>> map = new
>>>>>> HashMap<String, List<ColumnOrSuperColumn>>();
>>>>>> List<ColumnOrSuperColumn> list = new
>>>>>> ArrayList<ColumnOrSuperColumn>();
>>>>>> list.add(colOrSuperCol);
>>>>>> map.put(COLUMN_FAMILY_NAME, list);
>>>>>>
>>>>>> client.batch_insert(KEYSPACE_NAME, key, map,
>>>>>> ConsistencyLevel.ONE);
>>>>>>
>>>>>>
>>>>>> // The GET of the supercolumn
>>>>>> SlicePredicate predicate = new SlicePredicate(null, new
>>>>>> SliceRange(new byte
>>>>>> [0], new byte[0], false, 2));
>>>>>> ColumnParent parent = new ColumnParent(COLUMN_FAMILY_NAME,
>>>>>> key.getBytes());
>>>>>>
>>>>>> List<ColumnOrSuperColumn> columns = null;
>>>>>> columns = client.get_slice(KEYSPACE_NAME, key,
>>>>>> parent, predicate, ConsistencyLevel.ONE);
>>>>>>
>>>>>>
>>>>>> // delete the supercolumn
>>>>>> client.remove(KEYSPACE_NAME, key,new
>>>>>> ColumnPath(COLUMN_FAMILY_NAME, null, null),
>>>>>> System.currentTimeMillis(),ConsistencyLevel.ONE);
>>>>>>
>>>>>> // Do the get again
>>>>>>
>>>>>> When I try to delete the super column and then I try to read it again,
>>>>>> I get an exception thrown by cassandra
>>>>>>
>>>>>> org.apache.thrift.TApplicationException: Internal error processing
>>>>>> get_slice
>>>>>> at
>>>>>> org.apache.thrift.TApplicationException.read(TApplicationException.java:107)
>>>>>> at
>>>>>> org.apache.cassandra.service.Cassandra$Client.recv_get_slice(Cassandra.java:171)
>>>>>> at
>>>>>> org.apache.cassandra.service.Cassandra$Client.get_slice(Cassandra.java:150)
>>>>>> at
>>>>>> com.playdom.cassandra.datastore.CassandraDataStore.testGet(CassandraDataStore.java:233)
>>>>>> at
>>>>>> com.playdom.cassandra.test.TestCassandraDataStore.testSetAndGetTrial(TestCassandraDataStore.java:58)
>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>> at
>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>>> at
>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>> at junit.framework.TestCase.runTest(TestCase.java:168)
>>>>>> at junit.framework.TestCase.runBare(TestCase.java:134)
>>>>>> at junit.framework.TestResult$1.protect(TestResult.java:110)
>>>>>> at junit.framework.TestResult.runProtected(TestResult.java:128)
>>>>>> at junit.framework.TestResult.run(TestResult.java:113)
>>>>>> at junit.framework.TestCase.run(TestCase.java:124)
>>>>>> at junit.framework.TestSuite.runTest(TestSuite.java:232)
>>>>>> at junit.framework.TestSuite.run(TestSuite.java:227)
>>>>>> at junit.textui.TestRunner.doRun(TestRunner.java:116)
>>>>>> at
>>>>>> com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.java:94)
>>>>>> at junit.textui.TestRunner.doRun(TestRunner.java:109)
>>>>>> at
>>>>>> com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(IdeaTestRunner.java:22)
>>>>>> at
>>>>>> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:118)
>>>>>> at
>>>>>> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
>>>>>>
>>>>>> I was expecting a NotFoundException() since I thought the read will
>>>>>> not find anything. Also anytime I try to rerun this after the delete I
>>>>>> always get an exception in the reads.
>>>>>>
>>>>>> Am I doing something seriously wrong? Thanks a lot for your help
>>>>>>
>>>>>> Ray
>>>>>>
>>>>>
>>>>
>>>
>>
>