From user-return-19419-apmail-cassandra-user-archive=cassandra.apache.org@cassandra.apache.org Tue Aug 2 22:33:41 2011 Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D40DB61F3 for ; Tue, 2 Aug 2011 22:33:41 +0000 (UTC) Received: (qmail 7383 invoked by uid 500); 2 Aug 2011 22:33:39 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 7252 invoked by uid 500); 2 Aug 2011 22:33:38 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 7244 invoked by uid 99); 2 Aug 2011 22:33:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Aug 2011 22:33:38 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,MIME_QP_LONG_LINE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.113.200.5] (HELO homiemail-a81.g.dreamhost.com) (208.113.200.5) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Aug 2011 22:33:30 +0000 Received: from homiemail-a81.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a81.g.dreamhost.com (Postfix) with ESMTP id 311A4A8061 for ; Tue, 2 Aug 2011 15:33:08 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=thelastpickle.com; h=subject :references:from:content-type:in-reply-to:message-id:date:to :content-transfer-encoding:mime-version; q=dns; s= thelastpickle.com; b=tBaQinWPvMTWvK4e/l7VzkzBHn5dEOkAopws3MIR2AX PGkPkgYNOn65uPPJbx1HPd+G0Gg3uqdp4uMZ+r8TvbHjC+eV85Mm2CHlDYFI7hm4 LcEDJ+ONrfw+KPKtXh1T6LN2oSH8cM/++UJgCAjM3ELQIAZ7dCNUk7pRLZS8lV1g = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=thelastpickle.com; h= subject:references:from:content-type:in-reply-to:message-id:date :to:content-transfer-encoding:mime-version; s=thelastpickle.com; bh=mPRw/JTQcrCNPMQH1XgVYjtdsVI=; b=OM5g9Sj4TDfagc1479XM4+Ev/R2R 9wOJVJ1iYbRiRxrVaV/qMseno6cK361KHQdIqpbD9p5fKgx8kcg3cGMVbCJDmcvb GFK/75NL2cbVFMNfJgwTlDVIq9MC2oRHoIzRYPKYhonRYmDTmf/SgIknIddce3aZ h/p8M36V1m9/mxQ= Received: from [115.189.20.123] (unknown [115.189.20.123]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: aaron@thelastpickle.com) by homiemail-a81.g.dreamhost.com (Postfix) with ESMTPSA id 35643A805C for ; Tue, 2 Aug 2011 15:33:06 -0700 (PDT) Subject: Re: Problem with Schema change propagation time References: From: Aaron Morton Content-Type: multipart/alternative; boundary=Apple-Mail-2--990112860 X-Mailer: iPad Mail (8L1) In-Reply-To: Message-Id: <554627B6-7856-4CE8-B2E0-3582AEB2E398@thelastpickle.com> Date: Wed, 3 Aug 2011 10:35:27 +1200 To: "user@cassandra.apache.org" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (iPad Mail 8L1) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-2--990112860 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii You want to run the thrift function describe_schema_versions it will tell yo= u which nodes are on which schemas, and wait until there is a single version= . =46rom memory this is what the Cassandra Cli does, have a look in the code b= ase in the o.a.c.cli package. Cheers ----------------- Aaron Morton Freelance Cassandra Developer @aaronmorton http://www.thelastpickle.com On 3/08/2011, at 6:04 AM, Tharindu Mathew wrote: > I ran across a problem, when trying to execute the following code through H= ector. >=20 > private boolean createCF(String CFName) { > BasicColumnFamilyDefinition columnFamilyDefinition =3D new BasicCo= lumnFamilyDefinition(); > columnFamilyDefinition.setColumnType(ColumnType.STANDARD); > columnFamilyDefinition.setName(CFName); > columnFamilyDefinition.setKeyspaceName(ReceiverConstants.BAM_KEYSP= ACE); >=20 > synchronized (this) { > boolean cfDefFound =3D false; > for (ColumnFamilyDefinition cfDef : bamKeyspaceDefinition.getC= fDefs()) { > log.info("CF found : " + cfDef.getName()); > if (cfDef.getName().equals(CFName)) { > cfDefFound =3D true; > break; > } > } > // Column Family not found, so create it > if (!cfDefFound) { > ThriftCfDef cfDef =3D new ThriftCfDef(columnFamilyDefiniti= on); > cluster.addColumnFamily(cfDef); > } > cfList.add(CFName); > } > return true; > } >=20 > Even though the code block is synchronized, during a load other thread tha= t enter this block still does not see the CF has been added and results in [= 1] >=20 > A workaround would be going for a thread sleep. But that seems too hacky f= or me :(. Is there a way to properly fix this? Maybe a blocking method exist= s that doesn't return until this schema change is propagated through all nod= es. >=20 > BTW, I only have one node runnning. >=20 > Any help would be greatly appreciated. >=20 > --=20 > Regards, >=20 > Tharindu >=20 >=20 > [1] - >=20 > [2011-08-02 22:46:44,892] INFO {me.prettyprint.cassandra.hector.TimingLog= ger} - start[1312305404883] time[9] tag[META_WRITE.fail_] > me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequ= estException(why:CF is already defined in that keyspace.) > at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.transl= ate(ExceptionsTranslatorImpl.java:42) > at me.prettyprint.cassandra.service.ThriftCluster$3.execute(ThriftC= luster.java:68) > at me.prettyprint.cassandra.service.ThriftCluster$3.execute(ThriftC= luster.java:62) > at me.prettyprint.cassandra.service.Operation.executeAndSetResult(O= peration.java:101) > at me.prettyprint.cassandra.connection.HConnectionManager.operateWi= thFailover(HConnectionManager.java:156) > at me.prettyprint.cassandra.service.ThriftCluster.addColumnFamily(T= hriftCluster.java:72) > at org.wso2.carbon.bam.receiver.persistence.NoSQLDataStore.createCF(= NoSQLDataStore.java:168) > at org.wso2.carbon.bam.receiver.persistence.NoSQLDataStore.persistD= ata(NoSQLDataStore.java:124) > at org.wso2.carbon.bam.receiver.persistence.PersistenceManager.pers= istEvent(PersistenceManager.java:55) > at org.wso2.carbon.bam.receiver.internal.QueueWorker.run(QueueWorke= r.java:69) > at java.util.concurrent.Executors$RunnableAdapter.call(Executors.ja= va:441) > at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:30= 3) > at java.util.concurrent.FutureTask.run(FutureTask.java:138) > at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoo= lExecutor.java:886) > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExe= cutor.java:908) > at java.lang.Thread.run(Thread.java:619) > Caused by: InvalidRequestException(why:CF is already defined in that keysp= ace.) > at org.apache.cassandra.thrift.Cassandra$system_add_column_family_r= esult.read(Cassandra.java:23375) > at org.apache.cassandra.thrift.Cassandra$Client.recv_system_add_col= umn_family(Cassandra.java:1333) > at org.apache.cassandra.thrift.Cassandra$Client.system_add_column_f= amily(Cassandra.java:1308) > at me.prettyprint.cassandra.service.ThriftCluster$3.execute(ThriftC= luster.java:66) >=20 --Apple-Mail-2--990112860 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
You want to run the thrift functio= n describe_schema_versions it will tell you which nodes are on which schemas= , and wait until there is a single version.

=46rom m= emory this is what the Cassandra Cli does, have a look in the code base in t= he o.a.c.cli package.

Cheers



-----------------
Aaron Morton
Freelance= Cassandra Developer
@aaronmorton

On 3= /08/2011, at 6:04 AM, Tharindu Mathew <mccloud35@gmail.com> wrote:

I ran across a problem, when trying to execute the followi= ng code through Hector.

private boolean createCF(Str= ing CFName) {
        BasicColumnFamilyDefinit= ion columnFamilyDefinition =3D new BasicColumnFamilyDefinition();
        columnFamilyDefinition.setColumnType(Column= Type.STANDARD);
        columnFamilyDefinition= .setName(CFName);
        columnFamilyDefiniti= on.setKeyspaceName(ReceiverConstants.BAM_KEYSPACE);

        synchronized (this) {
<= div>            boolean cfDefFound =3D false;<= /div>
            for (ColumnFamilyDefinit= ion cfDef : bamKeyspaceDefinition.getCfDefs()) {
                if (cfDef.getNa= me().equals(CFName)) {
            &= nbsp;       cfDefFound =3D true;
    &nbs= p;               break;
  &= nbsp;             }
    &n= bsp;       }
          &nb= sp; // Column Family not found, so create it
            if (!cfDefFound) {
=                 ThriftCfDef cfDef =3D= new ThriftCfDef(columnFamilyDefinition);
      &nb= sp;         cluster.addColumnFamily(cfDef);
&n= bsp;           }
      &nb= sp;     cfList.add(CFName);
        }
        ret= urn true;
    }

Even though the= code block is synchronized, during a load other thread that enter this bloc= k 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 blo= cking method exists that doesn't return until this schema change is propagat= ed through all nodes.

BTW, I only have one node runnning.

=
Any help would be greatly appreciated.

--
Regar= ds,

Tharindu



me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidReques= tException(why:CF is already defined in that keyspace.)
at m= e.prettyprint.cassandra.service.ThriftCluster$3.execute(ThriftCluster.java:6= 8)
at me.prettyprint.cassandra.service.ThriftCluster$3.execute(ThriftCluste= r.java:62)
at m= e.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java= :101)
= at me.prettyprint.cassandra.connection.HConnectionManager.operateWit= hFailover(HConnectionManager.java:156)
at m= e.prettyprint.cassandra.service.ThriftCluster.addColumnFamily(ThriftCluster.= java:72)
= at org.wso2.carbon.bam.receiver.persistence.NoSQLDataStore.c= reateCF(NoSQLDataStore.java:168)
at o= rg.wso2.carbon.bam.receiver.persistence.NoSQLDataStore.persistData(NoSQLData= Store.java:124)
at org.wso2.carbon.bam.receiver.persistence.PersistenceManag= er.persistEvent(PersistenceManager.java:55)
at o= rg.wso2.carbon.bam.receiver.internal.QueueWorker.run(QueueWorker.java:69)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:44= 1)
at j= ava.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
= at j= ava.util.concurrent.FutureTask.run(FutureTask.java:138)
at j= ava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.jav= a:886)
= at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExec= utor.java:908)
at j= ava.lang.Thread.run(Thread.java:619)
Caused by: InvalidRequestExce= ption(why:CF is already defined in that keyspace.)
at org.apache.cassan= dra.thrift.Cassandra$system_add_column_family_result.read(Cassandra.java:233= 75)
at o= rg.apache.cassandra.thrift.Cassandra$Client.recv_system_add_column_family(Ca= ssandra.java:1333)
at org.apache.cassandra.thrift.Cassandra$Client.syst= em_add_column_family(Cassandra.java:1308)
at m= e.prettyprint.cassandra.service.ThriftCluster$3.execute(ThriftCluster.java:6= 6)

= --Apple-Mail-2--990112860--