Thanks Aaron.

I'll take a look at that. I'll refer this to the hector list as well, as I'm interested in an OOTB solution from the Hector API itself.

On Wed, Aug 3, 2011 at 4:05 AM, Aaron Morton <> wrote:
You want to run the thrift function describe_schema_versions it will tell you which nodes are on which schemas, and wait until there is a single version.

From memory this is what the Cassandra Cli does, have a look in the code base in the o.a.c.cli package.


Aaron Morton
Freelance Cassandra Developer

On 3/08/2011, at 6:04 AM, Tharindu Mathew <> wrote:

I ran across a problem, when trying to execute the following code through Hector.

private boolean createCF(String CFName) {
        BasicColumnFamilyDefinition columnFamilyDefinition = new BasicColumnFamilyDefinition();

        synchronized (this) {
            boolean cfDefFound = false;
            for (ColumnFamilyDefinition cfDef : bamKeyspaceDefinition.getCfDefs()) {
      "CF found : " + cfDef.getName());
                if (cfDef.getName().equals(CFName)) {
                    cfDefFound = true;
            // Column Family not found, so create it
            if (!cfDefFound) {
                ThriftCfDef cfDef = new ThriftCfDef(columnFamilyDefinition);
        return true;

Even though the code block is synchronized, during a load other thread that enter this block still does not see the CF has been added and results in [1]

A workaround would be going for a thread sleep. But that seems too hacky for me :(. Is there a way to properly fix this? Maybe a blocking method exists that doesn't return until this schema change is propagated through all nodes.

BTW, I only have one node runnning.

Any help would be greatly appreciated.



[1] -

[2011-08-02 22:46:44,892]  INFO {me.prettyprint.cassandra.hector.TimingLogger} -  start[1312305404883] time[9] tag[META_WRITE.fail_]
me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:CF is already defined in that keyspace.)
at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(
at me.prettyprint.cassandra.service.ThriftCluster$3.execute(
at me.prettyprint.cassandra.service.ThriftCluster$3.execute(
at me.prettyprint.cassandra.service.Operation.executeAndSetResult(
at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(
at me.prettyprint.cassandra.service.ThriftCluster.addColumnFamily(
at org.wso2.carbon.bam.receiver.persistence.NoSQLDataStore.createCF(
at org.wso2.carbon.bam.receiver.persistence.NoSQLDataStore.persistData(
at org.wso2.carbon.bam.receiver.persistence.PersistenceManager.persistEvent(
at java.util.concurrent.Executors$
at java.util.concurrent.FutureTask$Sync.innerRun(
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
at java.util.concurrent.ThreadPoolExecutor$
Caused by: InvalidRequestException(why:CF is already defined in that keyspace.)
at org.apache.cassandra.thrift.Cassandra$
at org.apache.cassandra.thrift.Cassandra$Client.recv_system_add_column_family(
at org.apache.cassandra.thrift.Cassandra$Client.system_add_column_family(
at me.prettyprint.cassandra.service.ThriftCluster$3.execute(