cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Omer van der Horst Jansen <ome...@yahoo.com>
Subject Did CASSANDRA-647 get fixed in 0.5?
Date Mon, 01 Feb 2010 21:26:00 GMT
I'm running 
into an issue with Cassandra 0.5 (the current release version) that 
sounds exactly like the description of issue CASSANDRA-647.

I'm 
using the Thrift Java API to store a couple of columns in a single row. A few seconds after
that my application deletes the entire row. A plain 
Cassandra.Client.get() will then throw a NotFoundException for that 
particular key, as expected. However, the key will still show up when executing a 
Cassandra.Client.get_range_slice query.

Here is some quick and 
dirty Java code that demonstrates the problem:

import 
java.util.List;

import org.apache.cassandra.service.*;
import 
org.apache.thrift.protocol.*;
import org.apache.thrift.transport.*;

public class Cassandra647TestApp
{
    /**
     * Demonstrates 
CASSANDRA-647 presence in Cassandra 0.5 release.
     * Requires an 
unmodified Cassandra configuration except that an 
     * 
OrderPreservingPartitioner should be used.
     */
    public 
static void main(String[] args) throws Exception
    {
        
String keyspace = "Keyspace1";
        String cf = "Standard1";
        String key = "testrow1";
        byte[] columnName = 
"colname".getBytes();
        byte[] data = "testdata".getBytes();

        TTransport transport = new TSocket("localhost", 9160);
        TProtocol protocol = new TBinaryProtocol(transport);
        
Cassandra.Client client = new Cassandra.Client(protocol);
        
transport.open();
        ColumnPath path = new ColumnPath(cf, null, 
columnName);

        client.insert(keyspace, key, path, data, 
System.currentTimeMillis(),
                ConsistencyLevel.ONE);

        Thread.sleep(1000);

        ColumnPath rowpath = new 
ColumnPath(cf, null, null);

        client.remove(keyspace, key, 
rowpath, System.currentTimeMillis(),
                
ConsistencyLevel.ONE);
        Thread.sleep(1000);

        try
        {
            ColumnOrSuperColumn cosc = client.get(keyspace, 
key, path,
                    ConsistencyLevel.ONE);
            
System.out.println("Whoops! NotFoundException not thrown!");
        }
        catch (NotFoundException e)
        {
            
System.out.println("OK, we got a NotFoundException");
        }

        ColumnParent parent = new ColumnParent(cf, null);
        
SlicePredicate predicate = new SlicePredicate();
        SliceRange 
range = new SliceRange();
        range.start = new byte[0];
        range.finish = new byte[0];
        predicate.slice_range = range;

        List<KeySlice> sliceList = client.get_range_slice(keyspace, parent,
                predicate, "", "", 1000, 
ConsistencyLevel.ONE);

        for (KeySlice k : sliceList)
        {
            System.out.println("Found key " + k.key);
            if (key.equals(k.key))
            {
                
System.out.println("but key " + k.key
                        + " 
should have been removed");
            }
        }
    }
}

Am I using the API correctly in the code above?

-Omer van der Horst Jansen



      

Mime
View raw message