Re: Random errors using phpcassa

2012-07-08 Thread Marco Matarazzo
In fact, phpcassa is doing his work quite well. 

The error seems to be coming from cassandra, even if I still have to understand 
why.

More precisely, the error is on the cql query prepare. I opened a bug for it, 
as we discovered the same problem on 3 different clusters. Maybe is something 
wrong with our installation or maintenance routine, but as far as i now we're 
doing everything correctly, so it's a bug to me.

Il giorno 08/lug/2012, alle ore 05:00, Tyler Hobbs ha scritto:

> phpcassa doesn't actually support CQL at all yet, it just doesn't stop you 
> from grabbing the connection and trying to run a cql query anyways.  So, I 
> would expect quite a few things to randomly break.
> 
> Additionally, you need to set the CQL API version to 3.0.0 (I believe) using 
> set_cql_version() on the connection in order to use cql3-specific behavior.
> 
> On Fri, Jul 6, 2012 at 5:37 PM, Marco Matarazzo  
> wrote:
> Greetings.
> 
> I am experiencing problems using a cassandra DB with phpcassa, but I am 
> unable to understand if the error is on phpcassa client itself or on 
> cassandra… As far as I understand, phpcassa just "pass" it to the thrift 
> layer, and errors I am seeing are coming back from cassandra itself, so I 
> guess it's some sort of cassandra problem (or, more easily, I am doing 
> something wrong but I don't know what). I hope I'm not too far from true.
> 
> 
> I am using CQL3 from php pages, and I wrote a class that basically wraps this 
> behaviour:
> 
> $this->pool=new 
> \phpcassa\Connection\ConnectionPool($keyspace,$servers);
> […yadda yadda…]
> $client=$this->pool->get()->client;
> 
> $result=$client->prepare_cql_query($query,\Cassandra\Compression::NONE);
> $itemid=$result->itemId;
> return $client->execute_prepared_cql_query($itemid,$args);
> 
> This works ALMOST always. Sometimes, hovewere, I get "random" errors on 
> queries that works. When I say "Query that works" it means that on error i 
> dump on screen the value of $query and $args, and this is always a valid 
> query that works, bot on the same page if I simply reload it, and on cqlsh 
> -3, with the very same parameters.
> 
> 
> Sample errors, and relative queries and CF schemas are:
> 
> ===
> 
> Executing [SELECT qt FROM cargobays USING CONSISTENCY QUORUM WHERE 
> corporation_id = ? and station_id = ? and item_id = ?] with 
> (edd051f0-44aa-4bc3-ad08-3174abcd1a0d,1110129,10025)
> error: No indexed columns present in by-columns clause with "equals" operator
> 
> cqlsh:goh_release> describe columnfamily cargobays
> 
> CREATE TABLE cargobays (
>   corporation_id ascii,
>   station_id ascii,
>   item_id ascii,
>   qt ascii,
>   PRIMARY KEY (corporation_id, station_id, item_id)
> ) WITH COMPACT STORAGE AND
>   comment='' AND
>   caching='KEYS_ONLY' AND
>   read_repair_chance=0.10 AND
>   gc_grace_seconds=864000 AND
>   min_compaction_threshold=4 AND
>   max_compaction_threshold=32 AND
>   replicate_on_write='true' AND
>   compaction_strategy_class='SizeTieredCompactionStrategy' AND
>   compression_parameters:sstable_compression='SnappyCompressor';
> 
> ===
> 
> Executing [UPDATE agents_skill USING CONSISTENCY QUORUM SET value = ? WHERE 
> agent_id = ? and skill = ?] with 
> (3,b716738b-95e6-4e22-9924-5334ee7f2f5d,pilot)
> error: line 1:78 mismatched input 'and' expecting EOF
> 
> cqlsh:goh_release> describe columnfamily agents_skill ;
> 
> CREATE TABLE agents_skill (
>   agent_id ascii,
>   skill ascii,
>   value ascii,
>   PRIMARY KEY (agent_id, skill)
> ) WITH COMPACT STORAGE AND
>   comment='' AND
>   caching='KEYS_ONLY' AND
>   read_repair_chance=0.10 AND
>   gc_grace_seconds=864000 AND
>   min_compaction_threshold=4 AND
>   max_compaction_threshold=32 AND
>   replicate_on_write='true' AND
>   compaction_strategy_class='SizeTieredCompactionStrategy' AND
>   compression_parameters:sstable_compression='SnappyCompressor';
> 
> 
> We have a cluster of 3 nodes, and the keyspace is defined as follow:
> 
> CREATE KEYSPACE v_release WITH strategy_class = 'SimpleStrategy'
>   AND strategy_options:replication_factor = '3';
> 
> 
> We're using (packaged) Cassandra 1.1.2 on an Ubuntu LTS 12.04.
> 
> 
> I really hope it's something that can be sorted out, because we're pretty 
> lost here.
> 
> Thank you.
> 
> --
> Marco Matarazzo
> 
> 
> 
> 
> 
> 
> 
> -- 
> Tyler Hobbs
> DataStax
> 

--
Marco Matarazzo
== Hex Keep ==

W: http://www.hexkeep.com
M: +39 347 8798528
E: marco.matara...@hexkeep.com

"You can learn more about a man
  in one hour of play
  than in one year of conversation.” - Plato






Re: JNA on Windows

2012-07-08 Thread aaron morton
Processes start differently on windows.

On windows it uses mklink to make a hard link
https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/utils/CLibrary.java#L170


Cheers

-
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 6/07/2012, at 5:57 AM, Fredrik Stigbäck wrote:

> Hello.
> I have a question regarding JNA and Windows.
> I read about the problem that when taking snapshots might require the
> process space x 2 due to how hardlinks are created.
> Is JNA for Windows supported?
> Looking at jira issue
> https://issues.apache.org/jira/browse/CASSANDRA-1371 looks like it but
> checking in the Cassandra code base
> org.apache.cassandra.utils.CLibrary the only thing I see, is
> Native.register("c") which tries to load the c-library but I think
> doesn't exists on Windows which will result in creating links with cmd
> or fsutil and which might then triggger these extensive memory
> requirements.
> I'd be happy if someone could shed some light on this issue.
> Regards
> /Fredrik



Re: CQL 3 with a right API

2012-07-08 Thread aaron morton
Row keys are distinct. 

Cheers

-
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 6/07/2012, at 7:30 AM, Shahryar Sedghi wrote:

> Hi
> 
> I am new to to Cassandra and we started with 1.1 and modeled everything with 
> Composite columns and wide rows and chose CQL 3 even if it is beta. Since I 
> could not find a way in Hector to set CQL 3, I started with Thrift and 
> prototyped all my scenarios with Thrift including retrieving all row keys 
> (without CQL). Recently I saw a JDBC driver for 1.1.1 and it is so promising 
> (slightly slower than thrift in most of my scenarios). Apparently  JDBC "will 
> be" the ultimate Java API for Cassandra, so the question is:
> 
> Since there is no distinct clause in CQL 3, is there a way to retrieve all 
> row keys "with JDBC" without browsing all columns of the CF (and make it 
> distinct yourself) ?
> 
> Thanks
> 
> Shahryar Sedghi
> 
> -- 
> "Life is what happens while you are making other plans." ~ John Lennon



Re: Multiple keyspace question

2012-07-08 Thread aaron morton
I would do a test to see the latency difference under load between having 1 KS 
with 5 CF's and 50 KS with 5 CF's. 

Your test will need to read and write to all the CF's. Having many CF's may 
result in more frequent memtables flushes. 

(Personally it's not an approach I would take.)

Cheers
 
-
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 7/07/2012, at 8:15 AM, Shahryar Sedghi wrote:

> Aaron
> 
> I am going to have many (over 50 eventually) keyspaces with limited number of 
> CFs (5-6) do you think this one can cause a problem too.
> 
> Thanks
> 
> On Fri, Jul 6, 2012 at 2:28 PM, aaron morton  wrote:
> Also, all CF's in the same KS share one commit log. So all writes for the row 
> row key, across all CF's, are committed at the same time. 
> 
> Some other settings, such as caches in 1.1, are machine wide. 
> 
> If you have a small KS for something like app config, I'd say go with 
> whatever feels right. If you are talking about two full "application" KS's I 
> would think about their prospective workloads and growth patterns. Will you 
> always want to manage the two together ?
> 
> Cheers
> 
> -
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
> 
> On 6/07/2012, at 9:47 PM, Robin Verlangen wrote:
> 
>> Hi Ben,
>> 
>> The amount of keyspaces is not the problem: the amount of column families 
>> is. Each column family adds a certain amount of memory usage to the system. 
>> You can cope with this by adding memory or using generic column families 
>> that store different types of data.
>> 
>> With kind regards,
>> 
>> Robin Verlangen
>> Software engineer
>> 
>> W http://www.robinverlangen.nl
>> E ro...@us2.nl
>> 
>> Disclaimer: The information contained in this message and attachments is 
>> intended solely for the attention and use of the named addressee and may be 
>> confidential. If you are not the intended recipient, you are reminded that 
>> the information remains the property of the sender. You must not use, 
>> disclose, distribute, copy, print or rely on this e-mail. If you have 
>> received this message in error, please contact the sender immediately and 
>> irrevocably delete this message and any copies.
>> 
>> 2012/7/6 Ben Kaehne 
>> Good evening,
>> 
>> I have read multiple keyspaces are bad before in a few discussions, but to 
>> what extent?
>> 
>> We have some reasonably powerful machines and looking to host an additional 
>> (currently we have 1) 2 keyspaces within our cassandra cluster (of 3 nodes, 
>> using RF3).
>> 
>> At what point does adding extra keyspaces start becoming an issue? Is there 
>> anything special we should be considering or watching out for as we 
>> implement this?
>> 
>> I could not imagine that all cassandra users out there are running one 
>> massive keyspace, and at the same time can not imaging that all cassandra 
>> users have multiple clusters just to host different keyspaces.
>> 
>> Regards.
>> 
>> -- 
>> -Ben
>> 
>> 
> 
> 
> 
> 
> -- 
> "Life is what happens while you are making other plans." ~ John Lennon



Re: Composite Slice Query returning non-sliced data

2012-07-08 Thread aaron morton
Something like:

This is how I did the write in CLI and this is what it printed.

and then

This is how I did the read in the CLI and this is what it printed. 

It's hard to imagine what data is in cassandra based on code. 

cheers
 
-
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 7/07/2012, at 1:28 PM, Sunit Randhawa wrote:

> Aaron,
> 
> For writing, i am using cli.
> Below is the piece of code that is reading column names of different types.
> 
> 
> Composite start = new Composite();
> 
>   start.addComponent(0, beginTime,
>   Composite.ComponentEquality.EQUAL);
>   
>   if (columns != null){
>   int colCount =1;
>   for (String colName : columns){
>   
> start.addComponent(colCount,colName,Composite.ComponentEquality.EQUAL);
>   colCount++;
>   }
>   }
> 
>   Composite finish = new Composite();
>   finish.addComponent(0, endTime,
>   Composite.ComponentEquality.EQUAL);
>   
>   if (columns != null){
>   int colCount =1;
>   for (String colName : columns){
>   if (colCount == columns.size())
>   finish.addComponent(colCount,colName+ 
> Character.MAX_VALUE,
> Composite.ComponentEquality.GREATER_THAN_EQUAL);
>   //Greater_than_equal is meant for any subslices 
> to A:B:C if searched on A:B
>   else
>   
> finish.addComponent(colCount,colName,Composite.ComponentEquality.EQUAL);
>   colCount++;
>   }
>   }
>   SliceQuery sq
> =  HFactory.createSliceQuery(keyspace, StringSerializer.get(),
>  new CompositeSerializer(),
>  StringSerializer.get());
>   sq.setColumnFamily(columnFamilyName);
> 
>   sq.setKey(key);
>   logger.debug("Start:"+start+",finish:"+finish);
>   sq.setRange(start, finish, false, 1);
> 
>   QueryResult> result = sq
>   .execute();
>   ColumnSlice orderedRows = result.get();
> 
> Please let me know if you additional info.
> 
> Thanks,
> Sunit.
> 
> On Fri, Jul 6, 2012 at 10:59 AM, aaron morton  wrote:
>> Can you provide an example of writing and reading column names of a
>> different type.
>> 
>> Thanks
>> 
>> -
>> Aaron Morton
>> Freelance Developer
>> @aaronmorton
>> http://www.thelastpickle.com
>> 
>> On 6/07/2012, at 11:30 AM, Sunit Randhawa wrote:
>> 
>> HI Aaron,
>> 
>> It is
>> 
>> create column family CF
>>   with comparator =
>> 'CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
>>   and key_validation_class = UTF8Type
>>   and default_validation_class = UTF8Type;
>> 
>> This is allowing me to insert column names of different type.
>> 
>> Thanks,
>> Sunit.
>> On Thu, Jul 5, 2012 at 4:24 PM, aaron morton 
>> wrote:
>> 
>> #2 has the Composite Column and #1 does not.
>> 
>> 
>> They are both strings.
>> 
>> 
>> All column names *must* be of the same type. What was your CF definition ?
>> 
>> 
>> Cheers
>> 
>> 
>> -
>> 
>> Aaron Morton
>> 
>> Freelance Developer
>> 
>> @aaronmorton
>> 
>> http://www.thelastpickle.com
>> 
>> 
>> On 6/07/2012, at 7:26 AM, Sunit Randhawa wrote:
>> 
>> 
>> Hello,
>> 
>> 
>> I have 2 Columns for a 'RowKey' as below:
>> 
>> 
>> #1 : set CF['RowKey']['1000']='A=1,B=2';
>> 
>> #2: set CF['RowKey']['1000:C1']='A=2,B=3'';
>> 
>> 
>> #2 has the Composite Column and #1 does not.
>> 
>> 
>> Now when I execute the Composite Slice query by 1000 and C1, I do get
>> 
>> both the columns above.
>> 
>> 
>> I am hoping get #2 only since I am specifically providing "C1" as
>> 
>> Start and Finish Composite Range with
>> 
>> Composite.ComponentEquality.EQUAL.
>> 
>> 
>> 
>> I am not sure if this is by design.
>> 
>> 
>> Thanks,
>> 
>> Sunit.
>> 
>> 
>> 
>> 



Re: Effect of rangequeries with RandomPartitioner

2012-07-08 Thread aaron morton
for background
http://wiki.apache.org/cassandra/FAQ#range_rp

It maps the start key to a token, and then scans X rows from their on CL number 
of nodes. Rows are stored in token order. 

Cheers

-
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 7/07/2012, at 11:52 PM, prasenjit mukherjee wrote:

> Wondering how a rangequery request is handled if RP is used.  Will the
> receiving node do a fan-out to all the nodes in the ring or it will
> just execute the rangequery on its own local partition ?
> 
> -- 
> Sent from my mobile device



Re: cannot build 1.1.2 from source

2012-07-08 Thread aaron morton
Did you try running ant clean first ?

Cheers

-
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 8/07/2012, at 1:57 PM, Arya Goudarzi wrote:

> Hi Fellows,
> 
> I used to be able to build cassandra 1.1 up to 1.1.1 with the same set
> of procedures by running ant on the same machine, but now the stuff
> associated with gen-cli-grammar breaks the build. Any advice will be
> greatly appreciated.
> 
> -Arya
> 
> Source:
> source tarball for 1.1.2 downloaded from one of the mirrors in
> cassandra.apache.org
> OS:
> Ubuntu 10.04 Precise 64bit
> Ant:
> Apache Ant(TM) version 1.8.2 compiled on December 3 2011
> Maven:
> Apache Maven 3.0.3 (r1075438; 2011-02-28 17:31:09+)
> Java:
> java version "1.6.0_32"
> Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
> Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode)
> 
> 
> 
> Buildfile: /home/arya/workspace/cassandra-1.1.2/build.xml
> 
> maven-ant-tasks-localrepo:
> 
> maven-ant-tasks-download:
> 
> maven-ant-tasks-init:
> 
> maven-declare-dependencies:
> 
> maven-ant-tasks-retrieve-build:
> 
> init-dependencies:
> [echo] Loading dependency paths from file:
> /home/arya/workspace/cassandra-1.1.2/build/build-dependencies.xml
> 
> init:
>[mkdir] Created dir: 
> /home/arya/workspace/cassandra-1.1.2/build/classes/main
>[mkdir] Created dir:
> /home/arya/workspace/cassandra-1.1.2/build/classes/thrift
>[mkdir] Created dir: /home/arya/workspace/cassandra-1.1.2/build/test/lib
>[mkdir] Created dir: 
> /home/arya/workspace/cassandra-1.1.2/build/test/classes
>[mkdir] Created dir: /home/arya/workspace/cassandra-1.1.2/src/gen-java
> 
> check-avro-generate:
> 
> avro-interface-generate-internode:
> [echo] Generating Avro internode code...
> 
> avro-generate:
> 
> build-subprojects:
> 
> check-gen-cli-grammar:
> 
> gen-cli-grammar:
> [echo] Building Grammar
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g
> 
> [java] warning(209):
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g:697:1:
> Multiple token rules can match input such as "'-'":
> IntegerNegativeLiteral, COMMENT
> [java]
> [java] As a result, token(s) COMMENT were disabled for that input
> [java] warning(209):
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g:628:1:
> Multiple token rules can match input such as "'I'": INCR, INDEX,
> Identifier
> [java]
> [java] As a result, token(s) INDEX,Identifier were disabled for that input
> [java] warning(209):
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g:628:1:
> Multiple token rules can match input such as "'0'..'9'": IP_ADDRESS,
> IntegerPositiveLiteral, DoubleLiteral, Identifier
> [java]
> [java] As a result, token(s)
> IntegerPositiveLiteral,DoubleLiteral,Identifier were disabled for that
> input
> [java] warning(209):
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g:628:1:
> Multiple token rules can match input such as "'T'": TRUNCATE, TTL,
> Identifier
> [java]
> [java] As a result, token(s) TTL,Identifier were disabled for that input
> [java] warning(209):
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g:628:1:
> Multiple token rules can match input such as "'A'": T__109,
> API_VERSION, AND, ASSUME, Identifier
> [java]
> [java] As a result, token(s) API_VERSION,AND,ASSUME,Identifier
> were disabled for that input
> [java] warning(209):
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g:628:1:
> Multiple token rules can match input such as "'E'": EXIT, Identifier
> [java]
> [java] As a result, token(s) Identifier were disabled for that input
> [java] warning(209):
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g:628:1:
> Multiple token rules can match input such as "'L'": LIST, LIMIT,
> Identifier
> [java]
> [java] As a result, token(s) LIMIT,Identifier were disabled for that input
> [java] warning(209):
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g:628:1:
> Multiple token rules can match input such as "'B'": BY, Identifier
> [java]
> [java] As a result, token(s) Identifier were disabled for that input
> [java] warning(209):
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g:628:1:
> Multiple token rules can match input such as "'O'": ON, Identifier
> [java]
> [java] As a result, token(s) Identifier were disabled for that input
> [java] warning(209):
> /home/arya/workspace/cassandra-1.1.2/src/java/org/apache/cassandra/cli/Cli.g:628:1:
> Multiple token rules can match input such as "'K'": KEYSPACE,
> KEYSPACES, Identifier
> [java]
> [java] As a result, token(s) KEYSPACES,Identifier were disabled
> for that input
> [java] warning(209):
> /home/arya/workspace/cassan

Re: Effect of rangequeries with RandomPartitioner

2012-07-08 Thread prasenjit mukherjee
Thanks Aaron for your response. Some follow up
questions/assumptions/clarifications :

1. With RandomPartitioner, on a given node, are the keys  sorted by
their hash_values or original/unhashed keys  ?
2. With RandomPartitioner, on a given node, are the columns (for a
given key)   always sorted by their column_names ?
3. From what I understand,  token = hash(key) for a RandomPartitioner,
and hence any key-range queries will return bogus results.  Although I
believe column-range-queries should succeed even in RP if they are
always sorted by column_names.

-Thanks,
Prasenjit

On Mon, Jul 9, 2012 at 12:17 AM, aaron morton  wrote:
> for background
> http://wiki.apache.org/cassandra/FAQ#range_rp
>
> It maps the start key to a token, and then scans X rows from their on CL
> number of nodes. Rows are stored in token order.
>
> Cheers
>
> -
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 7/07/2012, at 11:52 PM, prasenjit mukherjee wrote:
>
> Wondering how a rangequery request is handled if RP is used.  Will the
> receiving node do a fan-out to all the nodes in the ring or it will
> just execute the rangequery on its own local partition ?
>
> --
> Sent from my mobile device
>
>


Re: Effect of rangequeries with RandomPartitioner

2012-07-08 Thread samal
inline resp.

On Mon, Jul 9, 2012 at 10:18 AM, prasenjit mukherjee
wrote:

> Thanks Aaron for your response. Some follow up
> questions/assumptions/clarifications :
>
> 1. With RandomPartitioner, on a given node, are the keys  sorted by
> their hash_values or original/unhashed keys  ?
>

hash value,


> 2. With RandomPartitioner, on a given node, are the columns (for a
> given key)   always sorted by their column_names ?
>

yes, depends on comparator.


> 3. From what I understand,  token = hash(key) for a RandomPartitioner,
> and hence any key-range queries will return bogus results.


correct.


> Although I
> believe column-range-queries should succeed even in RP if they are
> always sorted by column_names.
>
> correct, depends on comparator.


-Thanks,
> Prasenjit
>
> On Mon, Jul 9, 2012 at 12:17 AM, aaron morton 
> wrote:
> > for background
> > http://wiki.apache.org/cassandra/FAQ#range_rp
> >
> > It maps the start key to a token, and then scans X rows from their on CL
> > number of nodes. Rows are stored in token order.
> >
> > Cheers
> >
> > -
> > Aaron Morton
> > Freelance Developer
> > @aaronmorton
> > http://www.thelastpickle.com
> >
> > On 7/07/2012, at 11:52 PM, prasenjit mukherjee wrote:
> >
> > Wondering how a rangequery request is handled if RP is used.  Will the
> > receiving node do a fan-out to all the nodes in the ring or it will
> > just execute the rangequery on its own local partition ?
> >
> > --
> > Sent from my mobile device
> >
> >
>