unsubscribe

2014-02-24 Thread flroche.ext
unsubscribe

_

Ce message et ses pieces jointes peuvent contenir des informations 
confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce 
message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages 
electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou 
falsifie. Merci.

This message and its attachments may contain confidential or privileged 
information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete 
this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been 
modified, changed or falsified.
Thank you.



Re: Performance problem with large wide row inserts using CQL

2014-02-24 Thread Sylvain Lebresne
On Fri, Feb 21, 2014 at 8:53 PM, Yogi Nerella  wrote:

> I am using CCM to install the servers, it is bringing in the source code,
> is there any option for CCM which I can set only to download the binary,
> just to make sure it is not bringing in the working copy of the code.
>

No there isn't. And though I'm happy to help you with CCM problems, it
would be nice to at least create a separate thread for this as it's pretty
much unrelated to the initial email of this thread.


>
> I am using the following statements to create Keyspace and table
> definition.
>
>  create keyspace test1 with replication = { 'class':'SimpleStrategy',
> 'replication_factor':1};
>
>  CREATE TABLE IF NOT EXISTS wide (
>   time varchar,
>   name varchar,
>   value varchar,
>   PRIMARY KEY (time,name))
>   WITH COMPACT STORAGE;
>
>
> On Fri, Feb 21, 2014 at 11:47 AM, Yogi Nerella wrote:
>
>> Sylvain,
>>
>> I am trying ccm to install and it does from source directory, I have
>> tried 2.0.4/3/2/1 and 1.2.15, all of them are reporting the same failure
>> after 127 records inserted.
>>
>> I am using 1.56.34 and 1.56.38 client both reports the same issue.
>>
>> Is something wrong with the client or the server, none of the server logs
>> show any error.
>>
>> Thanks,
>> Yogi
>>
>>
>> On Wed, Feb 19, 2014 at 11:36 PM, Sylvain Lebresne 
>> wrote:
>>
>>>
>>>
>>>
>>> On Wed, Feb 19, 2014 at 9:38 PM, Rüdiger Klaehn wrote:
>>>

 I have cloned the cassandra repo, applied the patch, and built it. But
 when I want to run the bechmark I get an exception. See below. I tried with
 a non-managed dependency to
 cassandra-driver-core-2.0.0-rc3-SNAPSHOT-jar-with-dependencies.jar, which I
 compiled from source because I read that that might help. But that did not
 make a difference.

 So currently I don't know how to give the patch a try. Any ideas?

 cheers,

 Rüdiger

 Exception in thread "main" java.lang.IllegalArgumentException:
 replicate_on_write is not a column defined in this metadata
 at
 com.datastax.driver.core.ColumnDefinitions.getAllIdx(ColumnDefinitions.java:273)
 at
 com.datastax.driver.core.ColumnDefinitions.getFirstIdx(ColumnDefinitions.java:279)
 at com.datastax.driver.core.Row.getBool(Row.java:117)
 at
 com.datastax.driver.core.TableMetadata$Options.(TableMetadata.java:474)
 at
 com.datastax.driver.core.TableMetadata.build(TableMetadata.java:107)
 at
 com.datastax.driver.core.Metadata.buildTableMetadata(Metadata.java:128)
 at com.datastax.driver.core.Metadata.rebuildSchema(Metadata.java:89)
 at
 com.datastax.driver.core.ControlConnection.refreshSchema(ControlConnection.java:259)
 at
 com.datastax.driver.core.ControlConnection.tryConnect(ControlConnection.java:214)
 at
 com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:161)
 at
 com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:77)
 at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:890)
 at
 com.datastax.driver.core.Cluster$Manager.newSession(Cluster.java:910)
 at
 com.datastax.driver.core.Cluster$Manager.access$200(Cluster.java:806)
 at com.datastax.driver.core.Cluster.connect(Cluster.java:158)
 at
 cassandra.CassandraTestMinimized$delayedInit$body.apply(CassandraTestMinimized.scala:31)
 at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
 at
 scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
 at scala.App$$anonfun$main$1.apply(App.scala:71)
 at scala.App$$anonfun$main$1.apply(App.scala:71)
 at scala.collection.immutable.List.foreach(List.scala:318)
 at
 scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
 at scala.App$class.main(App.scala:71)
 at
 cassandra.CassandraTestMinimized$.main(CassandraTestMinimized.scala:5)
 at
 cassandra.CassandraTestMinimized.main(CassandraTestMinimized.scala)

>>>
>>> I believe you've tried the cassandra trunk branch? trunk is basically
>>> the future Cassandra 2.1 and the driver is currently unhappy because the
>>> replicate_on_write option has been removed in that version. I'm supposed to
>>> have fixed that on the driver 2.0 branch like 2 days ago so maybe you're
>>> also using a slightly old version of the driver sources in there? Or maybe
>>> I've screwed up my fix, I'll double check. But anyway, it would be overall
>>> simpler to test with the cassandra-2.0 branch of Cassandra, with which you
>>> shouldn't run into that.
>>>
>>> --
>>> Sylvain
>>>
>>
>>
>


FW: Sporadic gossip exception on add node

2014-02-24 Thread Desimpel, Ignace
Had a look at the code, and this might be a race-condition like problem at the 
function StorageService::checkForEndpointCollision and 
StorageService::prepareReplacementInfo

To do a Gossiper.instance.doShadowRound(), the 
MessagingService.instance().listen(FBUtilities.getLocalAddress()) must be FULLY 
(accepting connections) running.
However , the listen function is starting SocketThread threads, but is not 
waiting for these to be started. So I think, at least in theory,  that the 
doShadowRound function will be sending messages, thus excepting answers, but 
there is no guarantee that the listeners are actually up and running.

As a test I modified the MessagingService::listen code by
SocketThread th = new SocketThread(ss, "ACCEPT-" + localEp);
   synchronized( th ) {
 th.start();
 try { th.wait(); } catch(Throwable tt){}
   }

And the SocketThread::run function
public void run()
   {
 synchronized( this ) {
   this.notifyAll();
 }

That way there is little chance the socket thread is not running yet (should be 
blocked in the server.accept call() ).


Regards,
Ignace Desimpel

From: Desimpel, Ignace [mailto:ignace.desim...@nuance.com]
Sent: donderdag 6 februari 2014 12:15
To: user@cassandra.apache.org
Subject: Sporadic gossip exception on add node

Environment : linux, cassandra 2.0.4, 3 node, embedded, byte ordered, LCS

When I add a node to the existing 3 node cluster I sometimes get the exception 
'Unable to gossip with any seeds ' listed below. If I just restart it without 
any change then mostly it works. Must be some timing issue.

The Cassandra at that time is configured using the Cassandra.yaml file
with the auto_bootstrap set true
and the initial_token set to something like : 00f35256, 041e692a, 0562d8b2, 
0930274a, 0b16ce96, 0c5b3e1e, 10cac47a, 12b16bc6, 13f5db4e, 186561aa, 1907996e, 
1c32b042, 1e19578e ..

The two seeds configured in this yaml are 10.164.8.250 and 10.164.8.249 and 
these are up and running.
The new node to add has ip 10.164.8.93

At the time of the exception, I do not get the gossip message 'Handshaking 
version with /10.164.8.93' on the seeds.
If the exception does not occurs, then I do get that gossip message 
'Handshaking version with /10.164.8.93' on the seed

2014-01-31 13:40:36.380 Loading persisted ring state
2014-01-31 13:40:36.386 Starting Messaging Service on port 9804
2014-01-31 13:40:36.408 Handshaking version with /10.164.8.250
2014-01-31 13:40:36.408 Handshaking version with /10.164.8.249
2014-01-31 13:41:07.415 Exception encountered during startup
java.lang.RuntimeException: Unable to gossip with any seeds
at 
org.apache.cassandra.gms.Gossiper.doShadowRound(Gossiper.java:1160) 
~[apache-cassandra-2.0.4-SNAPSHOT.jar:2.0.4-SNAPSHOT]
at 
org.apache.cassandra.service.StorageService.checkForEndpointCollision(StorageService.java:426)
 ~[apache-cassandra-2.0.4-SNAPSHOT.jar:2.0.4-SNAPSHOT]
at 
org.apache.cassandra.service.StorageService.joinTokenRing(StorageService.java:618)
 ~[apache-cassandra-2.0.4-SNAPSHOT.jar:2.0.4-SNAPSHOT]
at 
org.apache.cassandra.service.StorageService.initServer(StorageService.java:586) 
~[apache-cassandra-2.0.4-SNAPSHOT.jar:2.0.4-SNAPSHOT]
at 
org.apache.cassandra.service.StorageService.initServer(StorageService.java:485) 
~[apache-cassandra-2.0.4-SNAPSHOT.jar:2.0.4-SNAPSHOT]
at 
org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:346) 
~[apache-cassandra-2.0.4-SNAPSHOT.jar:2.0.4-SNAPSHOT]
at 
org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:461) 
~[apache-cassandra-2.0.4-SNAPSHOT.jar:2.0.4-SNAPSHOT]
at 
be.landc.services.search.server.db.baseserver.indexsearch.store.cassandra.CassandraStore$CassThread.startUpCassandra(CassandraStore.java:469)
 [landc-services-search-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT-87937]
at 
be.landc.services.search.server.db.baseserver.indexsearch.store.cassandra.CassandraStore$CassThread.run(CassandraStore.java:460)
 [landc-services-search-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT-87937]
java.lang.RuntimeException: Unable to gossip with any seeds
at 
org.apache.cassandra.gms.Gossiper.doShadowRound(Gossiper.java:1160)
at 
org.apache.cassandra.service.StorageService.checkForEndpointCollision(StorageService.java:426)
at 
org.apache.cassandra.service.StorageService.joinTokenRing(StorageService.java:618)
at 
org.apache.cassandra.service.StorageService.initServer(StorageService.java:586)
at 
org.apache.cassandra.service.StorageService.initServer(StorageService.java:485)
at 
org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:346)
at 
org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:461)
at 
be.landc.services.search.server.db.baseserver.indexsearch.store.

Re: Performance problem with large wide row inserts using CQL

2014-02-24 Thread Sylvain Lebresne
>
>
>
>>
>>> I still have some questions regarding the mapping. Please bear with me
>>> if these are stupid questions. I am quite new to Cassandra.
>>>
>>> The basic cassandra data model for a keyspace is something like this,
>>> right?
>>>
>>> SortedMap>
>>>  ^ row key. determines which server(s) the rest is
>>> stored on
>>>  ^ column key
>>>^
>>> timestamp (latest one wins)
>>>
>>> ^ value (can be size 0)
>>>
>>
>> It's a reasonable way to think of how things are stored internally, yes.
>> Though as DuyHai mentioned, the first map is really sorting by token and in
>> general that means you use mostly the sorting of the second map concretely.
>>
>>
> Yes, understood.
>
> So the first SortedMap is sorted on some kind of hash of the actual key to
> make sure the data gets evenly distributed along the nodes? What if my key
> is already a good hash: is there a way to use an identity function as a
> hash function (in CQL)?
>

It's possible, yes. The hash function we're talking about is what Cassandra
calls "the partitioner". You configure the partitioner in the yaml config
file and there is one partitioner, ByteOrderedPartitioner, that is
basically the identify function.
We however usually discourage user for using it because the partitioner is
global to a cluster and cannot be changed (you basically pick it at cluster
creation time and are stuck with it until the end of time), and since
ByteOrderedPartitioner can easily lead to hotspot in the data distribution
if you're not careful...For those reasons, the default partitioner is also
much more tested, and I can't remember anyone mentioning the partitioner
has been a bottleneck.

--
Sylvain


>
>
>>
>>> So if I have a table like the one in my benchmark (using blobs)
>>>
>>> CREATE TABLE IF NOT EXISTS test.wide (
>>>   time blob,
>>>   name blob,
>>>   value blob,
>>>   PRIMARY KEY (time,name))
>>>   WITH COMPACT STORAGE
>>>
>>> From reading http://www.datastax.com/dev/blog/thrift-to-cql3 it seems
>>> that
>>>
>>> - time maps to the row key and name maps to the column key without any
>>> overhead
>>> - value directly maps to value in the model above without any prefix
>>>
>>> is that correct, or is there some overhead involved in CQL over the raw
>>> model as described above? If so, where exactly?
>>>
>>
>> That's correct.
>> For completeness sake, if you were to remove the COMPACT STORAGE, there
>> would be some overhead in how it maps to the underlying column key, but
>> that overhead would buy you much more flexibility in how you could evolve
>> this table schema (you could add more CQL columns later if needs be, have
>> collections or have static columns following CASSANDRA-6561 that comes in
>> 2.0.6; none of which you can have with COMPACT STORAGE). Note that it's
>> perfectly fine to use COMPACT STORAGE if you know you don't and won't need
>> the additional flexibility, but I generally advise people to actually check
>> first that using COMPACT STORAGE does make a concrete and meaningful
>> difference for their use case (be careful with premature optimization
>> really).
>>
>
> In this case I am confident that the schema will not change. But there
> will be other tables built from the same data where I am not going to use
> compact storage.
>
> cheers,
>
> Rüdiger
>


Re: [OT]: Can I have a non-delivering subscription?

2014-02-24 Thread Edward Capriolo
You can setup the mail to deliver one per day as well.

On Saturday, February 22, 2014, Robert Wille  wrote:
> Yeah, it¹s called a rule. Set one up to delete everything from
> user@cassandra.apache.org.
>
> On 2/22/14, 10:32 AM, "Paul "LeoNerd" Evans" 
> wrote:
>
>>A question about the mailing list itself, rather than Cassandra.
>>
>>I've re-subscribed simply because I have to be subscribed in order to
>>send to the list, as I sometimes try to when people Cc questions about
>>my Net::Async::CassandraCQL perl module to me. However, if I want to
>>read the list, I usually do so on the online archives and not by mail.
>>
>>Is it possible to have a non-delivering subscription, which would let
>>me send messages, but doesn't deliver anything back to me?
>>
>>--
>>Paul "LeoNerd" Evans
>>
>>leon...@leonerd.org.uk
>>ICQ# 4135350   |  Registered Linux# 179460
>>http://www.leonerd.org.uk/
>
>
>

-- 
Sorry this was sent from mobile. Will do less grammar and spell check than
usual.


Are indexes replicated to all nodes?

2014-02-24 Thread Peter Lin
I was looking at the indexing code in Cassandra server and couldn't
determine if the indexes use the same replication factor as the keyspace.
When I print out the details of the keyspace, it correctly show the
replication factor, which "suggests" the index for a given partition only
lives on the same node.

I ask for a couple of reasons. Sometimes, users may want to be able to run
queries like these.

select * from MyColumnFamily where Column1='some1' or Column4='other1'

select * from MyColumnFamily where Column2 like '%OOP%' and Column5 like
'%architect%'

In our tooling, we've integrated Solr, so that we can do queries like this
with our query API. The query API looks like JPA/Hibernate, so we off load
the work to Solr when needed. If the indexes were replicated to all nodes
(aka partitions), Cassandra server could then use index joins and return
the results to the client.  The client can then merge the results.

What we do now is we query Solr to get the list of keys and then query
cassandra for the records by key.

anyone know the answer off hand?

thanks

peter


CQL decimal encoding

2014-02-24 Thread Ben Hood
Hi,

I'd like to implement decimal encoding for gocql but I'm wondering
what this should be compatible with. Is there some kind of wire format
that arbitrary precision numbers should adhere to to ensure
interoperability?

Cheers,

Ben


Re: Performance problem with large wide row inserts using CQL

2014-02-24 Thread Rüdiger Klaehn
On Mon, Feb 24, 2014 at 11:47 AM, Sylvain Lebresne wrote:

>
>>
>>>
 I still have some questions regarding the mapping. Please bear with me
 if these are stupid questions. I am quite new to Cassandra.

 The basic cassandra data model for a keyspace is something like this,
 right?

 SortedMap>
  ^ row key. determines which server(s) the rest is
 stored on
  ^ column key
^
 timestamp (latest one wins)

 ^ value (can be size 0)

>>>
>>> It's a reasonable way to think of how things are stored internally, yes.
>>> Though as DuyHai mentioned, the first map is really sorting by token and in
>>> general that means you use mostly the sorting of the second map concretely.
>>>
>>>
>> Yes, understood.
>>
>> So the first SortedMap is sorted on some kind of hash of the actual key
>> to make sure the data gets evenly distributed along the nodes? What if my
>> key is already a good hash: is there a way to use an identity function as a
>> hash function (in CQL)?
>>
>
> It's possible, yes. The hash function we're talking about is what
> Cassandra calls "the partitioner". You configure the partitioner in the
> yaml config file and there is one partitioner, ByteOrderedPartitioner, that
> is basically the identify function.
> We however usually discourage user for using it because the partitioner is
> global to a cluster and cannot be changed (you basically pick it at cluster
> creation time and are stuck with it until the end of time), and since
> ByteOrderedPartitioner can easily lead to hotspot in the data distribution
> if you're not careful...For those reasons, the default partitioner is also
> much more tested, and I can't remember anyone mentioning the partitioner
> has been a bottleneck.
>
> Thanks for the info. I thought that this might be possible to adjust on a
per-keyspace level.

But if you can only do this globally, then I will leave it alone. Other
than the (probably negibile) performance impact of hashing the hash again,
there is nothing wrong with doing so. Hashing a SHA1-hash will give a good
distribution.

anyway, this is getting a bit off-topic.

cheers,

Rüdiger


Re: CQL decimal encoding

2014-02-24 Thread Peter Lin
Not sure what you mean by the question.

Are you talking about the structure of BigDecimal in java? If that is your
question, the java's BigDecimal uses the first 4 bytes for scale and
remaining bytes for BigInteger




On Mon, Feb 24, 2014 at 10:47 AM, Ben Hood <0x6e6...@gmail.com> wrote:

> Hi,
>
> I'd like to implement decimal encoding for gocql but I'm wondering
> what this should be compatible with. Is there some kind of wire format
> that arbitrary precision numbers should adhere to to ensure
> interoperability?
>
> Cheers,
>
> Ben
>


Handling data consistency

2014-02-24 Thread Kasper Middelboe Petersen
Hi,

My requirements include a system that can handle friend based highscore
lists (as a user I have a bunch of friends from various social sites like
Facebook). The user must have a highscore list that consist of his friends
only.

I have implemented this using the users ID as partition key and the friends
score and id as clustering keys. This keeps reads of the highscore list
fast and straight forward.

Updating a highscore is a bit cumbersome and suffers from
read-before-write, but can largely be done without too much worry. The big
issue here is I need to know the exact old highscore to be able to set a
new one.

The big problem arise when a new user connects and have many friends that
needs to be added. This can end up being quite an extensive amount of
queries that has to happen and could take some time to do:
 - Lookup the friends user id based on the social credentials
 - Lookup the friends highscore
 - Lookup the users own highscore
 - Add friend with his highscore to self
 - Add self to with own highscore to friend
 - Do update to self with lastUpdatedFriends timestamp
 - Do update to friend with lastUpdatedFriends timestamp

Now if a new user has a bunch of friends this could end up being quite a
lot of queries - all suffering from the read-before-write problem. Should
any of the friends set a new highscore between the lookup and the writes
the highscore would never be set correctly and duplicates would happen.

I'm open to any suggestions ranging from how to model this differently to
avoid the read-before-write to how to do this without risking having
duplicate data that would be extremely painful to try and find again in
highscore lists?


Thanks,
Kasper


Re: CQL decimal encoding

2014-02-24 Thread Ben Hood
Hey Peter,

On Mon, Feb 24, 2014 at 5:25 PM, Peter Lin  wrote:
>
> Not sure what you mean by the question.
>
> Are you talking about the structure of BigDecimal in java? If that is your
> question, the java's BigDecimal uses the first 4 bytes for scale and
> remaining bytes for BigInteger

I'm talking about the encoding of an arbitrary precision value in a
platform neutral fashion such that interoperability between different
language bindings is assured.

Say you have an Java app writing to Cassandra and a Python app reading
this data back out - ideally all language bindings would pack and
unpack the data in an interoperable fashion. Also, I'm not sure what
restrictions the server imposes on the encoding of the decimal type -
can you for example just write any old (unchecked) bogus data into a
decimal column via CQL?

My situation is that I'm implementing the marshalling for the gocql
driver, which is a generic CQL driver for Go. So ideally I'd like to
provide an implementation that is generic across all applications.

I'm using the class big.Rat from the Go standard library, which
provides a similar interface to BigDecimal in Java and decimal.Decimal
in Python. It has it's own encoding/decoding functions, but this
format is specific to Go binary encoding and hence is not portable.

So I have taken cue from 4 byte scale/variable length numerator
strategy used by the Java BigDecimal and I've got something going
using that: https://github.com/gocql/gocql/pull/120

I guess I was looking for some kind of spec for the on-wire format of
the decimal type.

Or in the absence of a spec, just a heads up from other language
driver implementors as to what approach they've taken.

Does this make sense?

Cheers,

Ben


Re: CQL decimal encoding

2014-02-24 Thread Peter Lin
ok, I "think" I understand.

I took a look at the code. Java uses big endian encoding. I don't know if
GO defaults to big or little. In my port of Hector to C#, I reverse the
bytes due to the fact that .Net uses little endian.

hope that helps




On Mon, Feb 24, 2014 at 12:51 PM, Ben Hood <0x6e6...@gmail.com> wrote:

> Hey Peter,
>
> On Mon, Feb 24, 2014 at 5:25 PM, Peter Lin  wrote:
> >
> > Not sure what you mean by the question.
> >
> > Are you talking about the structure of BigDecimal in java? If that is
> your
> > question, the java's BigDecimal uses the first 4 bytes for scale and
> > remaining bytes for BigInteger
>
> I'm talking about the encoding of an arbitrary precision value in a
> platform neutral fashion such that interoperability between different
> language bindings is assured.
>
> Say you have an Java app writing to Cassandra and a Python app reading
> this data back out - ideally all language bindings would pack and
> unpack the data in an interoperable fashion. Also, I'm not sure what
> restrictions the server imposes on the encoding of the decimal type -
> can you for example just write any old (unchecked) bogus data into a
> decimal column via CQL?
>
> My situation is that I'm implementing the marshalling for the gocql
> driver, which is a generic CQL driver for Go. So ideally I'd like to
> provide an implementation that is generic across all applications.
>
> I'm using the class big.Rat from the Go standard library, which
> provides a similar interface to BigDecimal in Java and decimal.Decimal
> in Python. It has it's own encoding/decoding functions, but this
> format is specific to Go binary encoding and hence is not portable.
>
> So I have taken cue from 4 byte scale/variable length numerator
> strategy used by the Java BigDecimal and I've got something going
> using that: https://github.com/gocql/gocql/pull/120
>
> I guess I was looking for some kind of spec for the on-wire format of
> the decimal type.
>
> Or in the absence of a spec, just a heads up from other language
> driver implementors as to what approach they've taken.
>
> Does this make sense?
>
> Cheers,
>
> Ben
>


Re: CQL decimal encoding

2014-02-24 Thread Ben Hood
On Mon, Feb 24, 2014 at 6:09 PM, Peter Lin  wrote:
> I took a look at the code. Java uses big endian encoding. I don't know if GO
> defaults to big or little. In my port of Hector to C#, I reverse the bytes
> due to the fact that .Net uses little endian.

Cool - I'll take this as a spec - thanks for the heads up.


Re: CQL decimal encoding

2014-02-24 Thread Paul "LeoNerd" Evans
On Mon, 24 Feb 2014 17:51:54 +
Ben Hood <0x6e6...@gmail.com> wrote:

> Or in the absence of a spec, just a heads up from other language
> driver implementors as to what approach they've taken.

I reverse-engineered it by using cqlsh to insert lots of known
numerical values, then seeing what the returned binary values came out
as.

If you're interested in comparing, my encode/decode functions are here:

  
https://metacpan.org/source/PEVANS/Protocol-CassandraCQL-0.11/lib/Protocol/CassandraCQL/Type.pm#L175

  
https://metacpan.org/source/PEVANS/Protocol-CassandraCQL-0.11/lib/Protocol/CassandraCQL/Type.pm#L181

And the unit tests live here:

  https://metacpan.org/source/PEVANS/Protocol-CassandraCQL-0.11/t/02types.t#L111

-- 
Paul "LeoNerd" Evans

leon...@leonerd.org.uk
ICQ# 4135350   |  Registered Linux# 179460
http://www.leonerd.org.uk/


signature.asc
Description: PGP signature


Re: CQL decimal encoding

2014-02-24 Thread Ben Hood
Hey Paul,

On Mon, Feb 24, 2014 at 6:40 PM, Paul "LeoNerd" Evans
 wrote:
> And the unit tests live here:
>
>   
> https://metacpan.org/source/PEVANS/Protocol-CassandraCQL-0.11/t/02types.t#L111

Very cool - I'll port these examples to the gocql marshaling test
suite - kudos to you for reverse engineering the encoding :-)


Re: CQL decimal encoding

2014-02-24 Thread Peter Lin
I did the same thing :)

I inserted lots of bigDecimal in Cqlsh and read it from my C# client. Then
I did the opposite, inserts BigDecimal from C# and query it from cqlsh.
Once both directions worked, I had unit tests to make sure data is cross
platform compatible.

I know older versions of FluentCassandra handled BigDecimal incorrectly, so
any BigDecimal inserted from C# caused a stack overflow in cqlsh.




On Mon, Feb 24, 2014 at 1:49 PM, Ben Hood <0x6e6...@gmail.com> wrote:

> Hey Paul,
>
> On Mon, Feb 24, 2014 at 6:40 PM, Paul "LeoNerd" Evans
>  wrote:
> > And the unit tests live here:
> >
> >
> https://metacpan.org/source/PEVANS/Protocol-CassandraCQL-0.11/t/02types.t#L111
>
> Very cool - I'll port these examples to the gocql marshaling test
> suite - kudos to you for reverse engineering the encoding :-)
>


Re: CQL decimal encoding

2014-02-24 Thread Paul "LeoNerd" Evans
On Mon, 24 Feb 2014 13:55:07 -0500
Peter Lin  wrote:

> I did the same thing :)
> 
> I inserted lots of bigDecimal in Cqlsh and read it from my C# client.
> Then I did the opposite, inserts BigDecimal from C# and query it from
> cqlsh. Once both directions worked, I had unit tests to make sure
> data is cross platform compatible.

Maybe examples like this should be taken as a comment to the core
developers: Document your stuff better ;)

We client authors shouldn't have to do these reverse-engineering hacks.
It should have been written down in the spec.

-- 
Paul "LeoNerd" Evans

leon...@leonerd.org.uk
ICQ# 4135350   |  Registered Linux# 179460
http://www.leonerd.org.uk/


signature.asc
Description: PGP signature


Cassandra Version History

2014-02-24 Thread Timmy Turner
Hi,

is there a history/list showing which major (as in x.y) versions of
Cassandra were released on which date?

Or is the list on Wikipedia complete? Did 2.0 come after 1.2?

Thanks!


Re: CQL decimal encoding

2014-02-24 Thread Ben Hood
On Mon, Feb 24, 2014 at 7:02 PM, Paul "LeoNerd" Evans
 wrote:
> On Mon, 24 Feb 2014 13:55:07 -0500
> Peter Lin  wrote:
>
>> I did the same thing :)
>>
>> I inserted lots of bigDecimal in Cqlsh and read it from my C# client.
>> Then I did the opposite, inserts BigDecimal from C# and query it from
>> cqlsh. Once both directions worked, I had unit tests to make sure
>> data is cross platform compatible.


So I have a question about the encoding of 0: \x00\x00\x00\x00\x00.

Does this not result in 0/0 or do you just interpret the whole byte
sequence as meaning canonically 0?


> Maybe examples like this should be taken as a comment to the core
> developers: Document your stuff better ;)
>
> We client authors shouldn't have to do these reverse-engineering hacks.
> It should have been written down in the spec.


In an ideal world, this kind of thing would happen :-)


CQLException ?

2014-02-24 Thread Andrew Cobley
I’m just converting some code from SQL to CQL.  The code can throw a 
SQLException.  however I note that there is no equivalent in CQL, I’m just 
wondering whys this is the case ?

Regards
Andy


The University of Dundee is a registered Scottish Charity, No: SC015096


Re: Cassandra Version History

2014-02-24 Thread Jonathan Lacefield
Hello,

  Check out the full version list here:
https://issues.apache.org/jira/browse/CASSANDRA?selectedTab=com.atlassian.jira.plugin.system.project:versions-panel&subset=-1

Jonathan

Jonathan Lacefield
Solutions Architect, DataStax
(404) 822 3487






On Mon, Feb 24, 2014 at 2:14 PM, Timmy Turner  wrote:

> Hi,
>
> is there a history/list showing which major (as in x.y) versions of
> Cassandra were released on which date?
>
> Or is the list on Wikipedia complete? Did 2.0 come after 1.2?
>
> Thanks!
>


Re: CQL decimal encoding

2014-02-24 Thread Paul "LeoNerd" Evans
On Mon, 24 Feb 2014 19:14:48 +
Ben Hood <0x6e6...@gmail.com> wrote:

> So I have a question about the encoding of 0: \x00\x00\x00\x00\x00.

The first four octets are the decimal shift (0), and the remaining ones
(one in this case) encode a varint - 0 in this case. So it's

  0 * 10**0

literally zero.

Technically the decimal shift matters not for zero - any four bytes
could be given as the shift, ending in \x00, but 0 is the simplest.

-- 
Paul "LeoNerd" Evans

leon...@leonerd.org.uk
ICQ# 4135350   |  Registered Linux# 179460
http://www.leonerd.org.uk/


signature.asc
Description: PGP signature


Re: CQL decimal encoding

2014-02-24 Thread Theo Hultberg
I don't know if it's by design or if it's by oversight that the data types
aren't part of the binary protocol specification. I had to reverse engineer
how to encode and decode all of them for the Ruby driver. There were
definitely a few bugs in the first few versions that could have been
avoided if there was a specification available.

T#


On Mon, Feb 24, 2014 at 8:43 PM, Paul "LeoNerd" Evans <
leon...@leonerd.org.uk> wrote:

> On Mon, 24 Feb 2014 19:14:48 +
> Ben Hood <0x6e6...@gmail.com> wrote:
>
> > So I have a question about the encoding of 0: \x00\x00\x00\x00\x00.
>
> The first four octets are the decimal shift (0), and the remaining ones
> (one in this case) encode a varint - 0 in this case. So it's
>
>   0 * 10**0
>
> literally zero.
>
> Technically the decimal shift matters not for zero - any four bytes
> could be given as the shift, ending in \x00, but 0 is the simplest.
>
> --
> Paul "LeoNerd" Evans
>
> leon...@leonerd.org.uk
> ICQ# 4135350   |  Registered Linux# 179460
> http://www.leonerd.org.uk/
>


How should clients handle the user defined types in 2.1?

2014-02-24 Thread Theo Hultberg
(I posted this on the client-dev list the other day, but that list seems
dead so I'm cross posting, sorry if it's the wrong thing to do)

Hi,

Is there any documentation on how CQL clients should handle the new user
defined types coming in 2.1? There's nothing in the protocol specification
on how to handle custom types as far as I can see.

For example, I tried creating the "address" type from the description of
CASSANDRA-5590, and this is how its metadata looks (the metadata for a
query contains a column with a custom type and this is the description of
it):

org.apache.cassandra.db.marshal.UserType(user_defined_types,61646472657373,737472656574:org.apache.cassandra.db.marshal.UTF8Type,63697479:org.apache.cassandra.db.marshal.UTF8Type,7a69705f636f6465:org.apache.cassandra.db.marshal.Int32Type,70686f6e6573:org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type))

Is the client supposed to parse that description, and in that case how? I
could probably figure it out but it would be great if someone could point
me to the right docs.

yours,
Theo (author of cql-rb, the Ruby driver)


Re: Update multiple rows in a CQL lightweight transaction

2014-02-24 Thread Clint Kelly
Hi Tupshin,

Thanks for your help; I appreciate it.

Could I do something like the following?

Given the same table you started with:

x | y | t | z
---+---+---+
 a | 1 | 2 | 10
 a | 2 | 2 | 20

I'd like to write a compare-and-set that does something like:

"If there is a row with (x,y,t,z) = (a,1,2,10), then update/insert a
row with (x,y,t,z) = (a,3,4,5) and update/insert a row with (x,y,t,z)
= (a,4,5,6)."


I don't see how I could do this with what you outlined above---just
curious.  It seems like what I describe above under the hood would be
a compare-and-(batch)-set on a single wide row, so it maybe is
possible with the Thrift API (I have to check).

Thanks again!

Best regards,
Clint

On Sat, Feb 22, 2014 at 11:38 AM, Tupshin Harper  wrote:
> #5633 was actually closed  because the static columns feature
> (https://issues.apache.org/jira/browse/CASSANDRA-6561) which has been
> checked in to the 2.0 branch but is not yet part of a release (it will be in
> 2.0.6).
>
> That feature will let you update multiple rows within a single partition by
> doing a CAS write based on a static column shared by all rows within the
> partition.
>
> Example extracted from the ticket:
> CREATE TABLE foo (
> x text,
> y bigint,
> t bigint static,
> z bigint,
> PRIMARY KEY (x, y) );
>
> insert into foo (x,y,t, z) values ('a', 1, 1, 10);
> insert into foo (x,y,t, z) values ('a', 2, 2, 20);
>
> select * from foo;
>
> x | y | t | z
> ---+---+---+
>  a | 1 | 2 | 10
>  a | 2 | 2 | 20
> (Note that both values of "t" are 2 because it is static)
>
>
>  begin batch update foo set z = 1 where x = 'a' and y = 1; update foo set z
> = 2 where x = 'a' and y = 2 if t = 4; apply batch;
>
>  [applied] | x | y| t
> ---+---+--+---
>  False | a | null | 2
>
> (Both updates failed to apply because there was an unmet conditional on one
> of them)
>
> select * from foo;
>
>  x | y | t | z
> ---+---+---+
>  a | 1 | 2 | 10
>  a | 2 | 2 | 20
>
>
> begin batch update foo set z = 1 where x = 'a' and y = 1; update foo set z =
> 2 where x = 'a' and y = 2 if t = 2; apply batch;
>
>  [applied]
> ---
>   True
>
> (both updates succeeded because the check on t succeeded)
>
> select * from foo;
> x | y | t | z
> ---+---+---+---
>  a | 1 | 2 | 1
>  a | 2 | 2 | 2
>
> Hope this helps.
>
> -Tupshin
>
>
>
> On Fri, Feb 21, 2014 at 6:05 PM, DuyHai Doan  wrote:
>>
>> Hello Clint
>>
>>  The Resolution status of the JIRA is set to "Later", probably the
>> implementation is not done yet. The JIRA was opened to discuss about impl
>> strategy but nothing has been coded so far I guess.
>>
>>
>>
>> On Sat, Feb 22, 2014 at 12:02 AM, Clint Kelly 
>> wrote:
>>>
>>> Folks,
>>>
>>> Does anyone know how I can modify multiple rows at once in a
>>> lightweight transaction in CQL3?
>>>
>>> I saw the following ticket:
>>>
>>> https://issues.apache.org/jira/browse/CASSANDRA-5633
>>>
>>> but it was not obvious to me from the comments how (or whether) this
>>> got resolved.  I also couldn't find anything in the DataStax
>>> documentation about how to perform these operations.
>>>
>>> I'm in particular interested in how to perform a compare-and-set
>>> operation that modifies multiple rows (with the same partition key)
>>> using the DataStax Java driver.
>>>
>>> Thanks!
>>>
>>> Best regards,
>>> Clint
>>
>>
>


Re: CQL decimal encoding

2014-02-24 Thread Ben Hood
On Mon, Feb 24, 2014 at 7:43 PM, Paul "LeoNerd" Evans
 wrote:
> On Mon, 24 Feb 2014 19:14:48 +
> Ben Hood <0x6e6...@gmail.com> wrote:
>
>> So I have a question about the encoding of 0: \x00\x00\x00\x00\x00.
>
> The first four octets are the decimal shift (0), and the remaining ones
> (one in this case) encode a varint - 0 in this case. So it's
>
>   0 * 10**0
>
> literally zero.
>
> Technically the decimal shift matters not for zero - any four bytes
> could be given as the shift, ending in \x00, but 0 is the simplest.

OK, that makes sense. I was getting confused by the Go API for
decimals, which doesn't let you set the scale to 0 (because it results
in / by 0 error). So I'll have to look into that particular API a bit
further.


Re: CQL decimal encoding

2014-02-24 Thread Ben Hood
On Mon, Feb 24, 2014 at 7:50 PM, Theo Hultberg  wrote:
> I don't know if it's by design or if it's by oversight that the data types
> aren't part of the binary protocol specification. I had to reverse engineer
> how to encode and decode all of them for the Ruby driver. There were
> definitely a few bugs in the first few versions that could have been avoided
> if there was a specification available.

Yes, it would be nice and would improve the overall quality of all of
the client drivers.


Re: How should clients handle the user defined types in 2.1?

2014-02-24 Thread Ben Hood
On Mon, Feb 24, 2014 at 7:52 PM, Theo Hultberg  wrote:
> (I posted this on the client-dev list the other day, but that list seems
> dead so I'm cross posting, sorry if it's the wrong thing to do)

I didn't even realize there was a list for driver implementors - is
this used at all? Is it worth being on this list?


Re: Update multiple rows in a CQL lightweight transaction

2014-02-24 Thread Tupshin Harper
Hi Clint,

That does appear to be an omission in CQL3. It would be possible to
simulate it by doing
BEGIN BATCH
UPDATE foo SET z = 10 WHERE x = 'a' AND y = 1 IF t= 2 AND z=10;
UPDATE foo SET t = 5,z=6 where x = 'a' AND y = 4
APPLY BATCH;

However, this does a redundant write to the first row if the condition
holds, and I certainly wouldn't recommend doing that routinely.

Alternatively, depending on your needs, you might be able to use a static
column (coming with 2.0.6) as your conditional flag, as that column is
shared by all rows in the partition.

-Tupshin


On Mon, Feb 24, 2014 at 3:57 PM, Clint Kelly  wrote:

> Hi Tupshin,
>
> Thanks for your help; I appreciate it.
>
> Could I do something like the following?
>
> Given the same table you started with:
>
> x | y | t | z
> ---+---+---+
>  a | 1 | 2 | 10
>  a | 2 | 2 | 20
>
> I'd like to write a compare-and-set that does something like:
>
> "If there is a row with (x,y,t,z) = (a,1,2,10), then update/insert a
> row with (x,y,t,z) = (a,3,4,5) and update/insert a row with (x,y,t,z)
> = (a,4,5,6)."
>
>
> I don't see how I could do this with what you outlined above---just
> curious.  It seems like what I describe above under the hood would be
> a compare-and-(batch)-set on a single wide row, so it maybe is
> possible with the Thrift API (I have to check).
>
> Thanks again!
>
> Best regards,
> Clint
>
> On Sat, Feb 22, 2014 at 11:38 AM, Tupshin Harper 
> wrote:
> > #5633 was actually closed  because the static columns feature
> > (https://issues.apache.org/jira/browse/CASSANDRA-6561) which has been
> > checked in to the 2.0 branch but is not yet part of a release (it will
> be in
> > 2.0.6).
> >
> > That feature will let you update multiple rows within a single partition
> by
> > doing a CAS write based on a static column shared by all rows within the
> > partition.
> >
> > Example extracted from the ticket:
> > CREATE TABLE foo (
> > x text,
> > y bigint,
> > t bigint static,
> > z bigint,
> > PRIMARY KEY (x, y) );
> >
> > insert into foo (x,y,t, z) values ('a', 1, 1, 10);
> > insert into foo (x,y,t, z) values ('a', 2, 2, 20);
> >
> > select * from foo;
> >
> > x | y | t | z
> > ---+---+---+
> >  a | 1 | 2 | 10
> >  a | 2 | 2 | 20
> > (Note that both values of "t" are 2 because it is static)
> >
> >
> >  begin batch update foo set z = 1 where x = 'a' and y = 1; update foo
> set z
> > = 2 where x = 'a' and y = 2 if t = 4; apply batch;
> >
> >  [applied] | x | y| t
> > ---+---+--+---
> >  False | a | null | 2
> >
> > (Both updates failed to apply because there was an unmet conditional on
> one
> > of them)
> >
> > select * from foo;
> >
> >  x | y | t | z
> > ---+---+---+
> >  a | 1 | 2 | 10
> >  a | 2 | 2 | 20
> >
> >
> > begin batch update foo set z = 1 where x = 'a' and y = 1; update foo set
> z =
> > 2 where x = 'a' and y = 2 if t = 2; apply batch;
> >
> >  [applied]
> > ---
> >   True
> >
> > (both updates succeeded because the check on t succeeded)
> >
> > select * from foo;
> > x | y | t | z
> > ---+---+---+---
> >  a | 1 | 2 | 1
> >  a | 2 | 2 | 2
> >
> > Hope this helps.
> >
> > -Tupshin
> >
> >
> >
> > On Fri, Feb 21, 2014 at 6:05 PM, DuyHai Doan 
> wrote:
> >>
> >> Hello Clint
> >>
> >>  The Resolution status of the JIRA is set to "Later", probably the
> >> implementation is not done yet. The JIRA was opened to discuss about
> impl
> >> strategy but nothing has been coded so far I guess.
> >>
> >>
> >>
> >> On Sat, Feb 22, 2014 at 12:02 AM, Clint Kelly 
> >> wrote:
> >>>
> >>> Folks,
> >>>
> >>> Does anyone know how I can modify multiple rows at once in a
> >>> lightweight transaction in CQL3?
> >>>
> >>> I saw the following ticket:
> >>>
> >>> https://issues.apache.org/jira/browse/CASSANDRA-5633
> >>>
> >>> but it was not obvious to me from the comments how (or whether) this
> >>> got resolved.  I also couldn't find anything in the DataStax
> >>> documentation about how to perform these operations.
> >>>
> >>> I'm in particular interested in how to perform a compare-and-set
> >>> operation that modifies multiple rows (with the same partition key)
> >>> using the DataStax Java driver.
> >>>
> >>> Thanks!
> >>>
> >>> Best regards,
> >>> Clint
> >>
> >>
> >
>


Re: Update multiple rows in a CQL lightweight transaction

2014-02-24 Thread Tupshin Harper
And, FWIW, I was just informed that the ticket that would have the actual
functionality you are looking for exists, but is not scheduled for
implementation due to lack of agreement about syntax to make it work:
https://issues.apache.org/jira/browse/CASSANDRA-5633

-Tupshin


On Mon, Feb 24, 2014 at 5:32 PM, Tupshin Harper  wrote:

> Hi Clint,
>
> That does appear to be an omission in CQL3. It would be possible to
> simulate it by doing
> BEGIN BATCH
> UPDATE foo SET z = 10 WHERE x = 'a' AND y = 1 IF t= 2 AND z=10;
> UPDATE foo SET t = 5,z=6 where x = 'a' AND y = 4
> APPLY BATCH;
>
> However, this does a redundant write to the first row if the condition
> holds, and I certainly wouldn't recommend doing that routinely.
>
> Alternatively, depending on your needs, you might be able to use a static
> column (coming with 2.0.6) as your conditional flag, as that column is
> shared by all rows in the partition.
>
> -Tupshin
>
>
>
> On Mon, Feb 24, 2014 at 3:57 PM, Clint Kelly wrote:
>
>> Hi Tupshin,
>>
>> Thanks for your help; I appreciate it.
>>
>> Could I do something like the following?
>>
>> Given the same table you started with:
>>
>> x | y | t | z
>> ---+---+---+
>>  a | 1 | 2 | 10
>>  a | 2 | 2 | 20
>>
>> I'd like to write a compare-and-set that does something like:
>>
>> "If there is a row with (x,y,t,z) = (a,1,2,10), then update/insert a
>> row with (x,y,t,z) = (a,3,4,5) and update/insert a row with (x,y,t,z)
>> = (a,4,5,6)."
>>
>>
>> I don't see how I could do this with what you outlined above---just
>> curious.  It seems like what I describe above under the hood would be
>> a compare-and-(batch)-set on a single wide row, so it maybe is
>> possible with the Thrift API (I have to check).
>>
>> Thanks again!
>>
>> Best regards,
>> Clint
>>
>> On Sat, Feb 22, 2014 at 11:38 AM, Tupshin Harper 
>> wrote:
>> > #5633 was actually closed  because the static columns feature
>> > (https://issues.apache.org/jira/browse/CASSANDRA-6561) which has been
>> > checked in to the 2.0 branch but is not yet part of a release (it will
>> be in
>> > 2.0.6).
>> >
>> > That feature will let you update multiple rows within a single
>> partition by
>> > doing a CAS write based on a static column shared by all rows within the
>> > partition.
>> >
>> > Example extracted from the ticket:
>> > CREATE TABLE foo (
>> > x text,
>> > y bigint,
>> > t bigint static,
>> > z bigint,
>> > PRIMARY KEY (x, y) );
>> >
>> > insert into foo (x,y,t, z) values ('a', 1, 1, 10);
>> > insert into foo (x,y,t, z) values ('a', 2, 2, 20);
>> >
>> > select * from foo;
>> >
>> > x | y | t | z
>> > ---+---+---+
>> >  a | 1 | 2 | 10
>> >  a | 2 | 2 | 20
>> > (Note that both values of "t" are 2 because it is static)
>> >
>> >
>> >  begin batch update foo set z = 1 where x = 'a' and y = 1; update foo
>> set z
>> > = 2 where x = 'a' and y = 2 if t = 4; apply batch;
>> >
>> >  [applied] | x | y| t
>> > ---+---+--+---
>> >  False | a | null | 2
>> >
>> > (Both updates failed to apply because there was an unmet conditional on
>> one
>> > of them)
>> >
>> > select * from foo;
>> >
>> >  x | y | t | z
>> > ---+---+---+
>> >  a | 1 | 2 | 10
>> >  a | 2 | 2 | 20
>> >
>> >
>> > begin batch update foo set z = 1 where x = 'a' and y = 1; update foo
>> set z =
>> > 2 where x = 'a' and y = 2 if t = 2; apply batch;
>> >
>> >  [applied]
>> > ---
>> >   True
>> >
>> > (both updates succeeded because the check on t succeeded)
>> >
>> > select * from foo;
>> > x | y | t | z
>> > ---+---+---+---
>> >  a | 1 | 2 | 1
>> >  a | 2 | 2 | 2
>> >
>> > Hope this helps.
>> >
>> > -Tupshin
>> >
>> >
>> >
>> > On Fri, Feb 21, 2014 at 6:05 PM, DuyHai Doan 
>> wrote:
>> >>
>> >> Hello Clint
>> >>
>> >>  The Resolution status of the JIRA is set to "Later", probably the
>> >> implementation is not done yet. The JIRA was opened to discuss about
>> impl
>> >> strategy but nothing has been coded so far I guess.
>> >>
>> >>
>> >>
>> >> On Sat, Feb 22, 2014 at 12:02 AM, Clint Kelly 
>> >> wrote:
>> >>>
>> >>> Folks,
>> >>>
>> >>> Does anyone know how I can modify multiple rows at once in a
>> >>> lightweight transaction in CQL3?
>> >>>
>> >>> I saw the following ticket:
>> >>>
>> >>> https://issues.apache.org/jira/browse/CASSANDRA-5633
>> >>>
>> >>> but it was not obvious to me from the comments how (or whether) this
>> >>> got resolved.  I also couldn't find anything in the DataStax
>> >>> documentation about how to perform these operations.
>> >>>
>> >>> I'm in particular interested in how to perform a compare-and-set
>> >>> operation that modifies multiple rows (with the same partition key)
>> >>> using the DataStax Java driver.
>> >>>
>> >>> Thanks!
>> >>>
>> >>> Best regards,
>> >>> Clint
>> >>
>> >>
>> >
>>
>
>


Re: abusing cassandra's multi DC abilities

2014-02-24 Thread Jared Biel
Have you heard of this https://github.com/Comcast/cmb? Maybe it's along the
path of what you're looking for.


On 22 February 2014 22:33, Jonathan Haddad  wrote:

> Upfront TLDR: We want to do stuff (reindex documents, bust cache) when
> changed data from DC1 shows up in DC2.
>
> Full Story:
> We're planning on adding data centers throughout the US.  Our platform is
> used for business communications.  Each DC currently utilizes elastic
> search and redis.  A message can be sent from one user to another, and the
> intent is that it would be seen in near-real-time.  This means that 2
> people may be using different data centers, and the messages need to
> propagate from one to the other.
>
> On the plus side, we know we get this with Cassandra (fist pump) but the
> other pieces, not so much.  Even if they did work, there's all sorts of
> race conditions that could pop up from having different pieces of our
> architecture communicating over different channels.  From this, we've
> arrived at the idea that since Cassandra is the authoritative data source,
> we might be able to trigger events in DC2 based on activity coming through
> either the commit log or some other means.  One idea was to use a CF with a
> low gc time as a means of transporting messages between DCs, and watching
> the commit logs for deletes to that CF in order to know when we need to do
> things like reindex a document (or a new document), bust cache, etc.
>  Facebook did something similar with their modifications to MySQL to
> include cache keys in the replication log.
>
> Assuming this is sane, I'd want to avoid having the same event register on
> 3 servers, thus registering 3 items in the queue when only one should be
> there.  So, for any piece of data replicated from the other DC, I'd need a
> way to determine if it was supposed to actually trigger the event or not.
>  (Maybe it looks at the token and determines if the current server falls in
> the token range?)  Or is there a better way?
>
> So, my questions to all ye Cassandra users:
>
> 1. Is this is even sane?
> 2. Is anyone doing it?
>
> --
> Jon Haddad
> http://www.rustyrazorblade.com
> skype: rustyrazorblade
>


Cassandra 2.0.5 Configuration

2014-02-24 Thread Timmy Turner
Hi,

when building and running Cassandra 2.0.5 from the git repository, the log
is full of lines like these

00:01:42.286 [CompactionExecutor:1] DEBUG
o.a.c.d.compaction.CompactionManager - Checking system.local

When building and running 2.1.0/trunk the log settings are however fine. Is
there any way I can lower the log setting in 2.0.5?

I already tried setting

log4j.rootLogger=ERROR,stdout,R

it in conf/log4j-server.properties, but that did not seem to have any
effect.


Thanks!


Re: Handling data consistency

2014-02-24 Thread Steven A Robenalt
Hi Kasper,

I am assuming that your friend list is symmetric (i.e. If I am your friend
then you are also my friend), which your comments seem to indicate.

First, I would suggest that you drop the friends score as a part of the
clustering key, which eliminates the need to read-before-write.

With that in mind, here's what I'd recommend:

1) Each user has their own high score and timestamp as part of their own
attributes (thus keyed to their own user id).

2) Each user also has a list of their own friends, keyed to their own user
id and the friend's user_id, and including the friend's high score and
updated time as attributes.

3) When I add a friend, I copy their high score and timestamp to my own
friends list, and I copy my current high score and timestamp to their
friends list.

4) When I update my own high score, I grab the ids of all of my friends
from my own friends list and push my new high score and timestamp to each
of them.

5) When I remove a friend, I delete myself from their friends list and them
from mine.

6) When I view any friends list, the result must be sorted at that time,
presumably by descending high score (since the score is no longer part of
the clustering key).

There's a couple of potential conflicts in this strategy, which may occur
(for example) if my friend updates a high score at the same time I drop
them as a friend (they would end up re-inserting themselves to my friend
list after I dropped them). In this case, I'd need to simply drop them
again. This may or may not be acceptable in your application. Most conflict
situations could be resolved with use of lightweight transactions if you
want to sacrifice performance (and assuming that the condition happens
often enough to warrant such treatment).

For performance reasons, it may also be desirable to lump all of the high
score updates for a user in a batch statement if you have the option to do
so.

Anyway, that eliminates the read-before-write problem, and also insures
that if a high score is missed at the time a new user is added as a friend,
it can at least be updated later with the correct value. Not sure how much
help that is, but maybe it'll give you some ideas you can experiment with.

Steve


On Mon, Feb 24, 2014 at 9:47 AM, Kasper Middelboe Petersen <
kas...@sybogames.com> wrote:

> Hi,
>
> My requirements include a system that can handle friend based highscore
> lists (as a user I have a bunch of friends from various social sites like
> Facebook). The user must have a highscore list that consist of his friends
> only.
>
> I have implemented this using the users ID as partition key and the
> friends score and id as clustering keys. This keeps reads of the highscore
> list fast and straight forward.
>
> Updating a highscore is a bit cumbersome and suffers from
> read-before-write, but can largely be done without too much worry. The big
> issue here is I need to know the exact old highscore to be able to set a
> new one.
>
> The big problem arise when a new user connects and have many friends that
> needs to be added. This can end up being quite an extensive amount of
> queries that has to happen and could take some time to do:
>  - Lookup the friends user id based on the social credentials
>  - Lookup the friends highscore
>  - Lookup the users own highscore
>  - Add friend with his highscore to self
>  - Add self to with own highscore to friend
>  - Do update to self with lastUpdatedFriends timestamp
>  - Do update to friend with lastUpdatedFriends timestamp
>
> Now if a new user has a bunch of friends this could end up being quite a
> lot of queries - all suffering from the read-before-write problem. Should
> any of the friends set a new highscore between the lookup and the writes
> the highscore would never be set correctly and duplicates would happen.
>
> I'm open to any suggestions ranging from how to model this differently to
> avoid the read-before-write to how to do this without risking having
> duplicate data that would be extremely painful to try and find again in
> highscore lists?
>
>
> Thanks,
> Kasper
>



-- 
Steve Robenalt
Software Architect
HighWire | Stanford University
425 Broadway St, Redwood City, CA 94063

srobe...@stanford.edu
http://highwire.stanford.edu


RE: Bootstrap stuck: vnode enabled 1.2.12

2014-02-24 Thread Arindam Barua

The host would not join the ring after more clean bootstrap attempts.

Noticed nodetool netstats, even though doesn't repair any streaming, does 
constantly report "Nothing streaming from" 3 specific hosts in the ring.

$ nodetool netstats
xss =  -ea -d64 -javaagent:/usr/local/cassandra/bin/../lib/jamm-0.2.5.jar 
-XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms8043M -Xmx8043M 
-Xmn800M -XX:+HeapDumpOnOutOfMemoryError -Xss256k
Mode: JOINING
Not sending any streams.
Nothing streaming from /10.67.XXX.XXX
Nothing streaming from /10.67.XXX.XXX
Nothing streaming from /10.67.XXX.XXX

Today when I had to do some unrelated maintenance and attempted to drain the 
hosts mentioned above before restarting cassandra, the drain would just hang. 
Other hosts in the ring did not have any issue.
Also the original host that is stuck in the joining state, logged the following:

[24/02/2014:15:49:42 PST] GossipTasks:1: ERROR AbstractStreamSession.java (line 
110) Stream failed because /10.67.XXX.XXX died or was restarted/removed 
(streams may still be active in background, but further streams won't be 
started)
[24/02/2014:15:49:42 PST] GossipTasks:1:  WARN RangeStreamer.java (line 246) 
Streaming from /10.67.XXX.XXX failed


From: Arindam Barua [mailto:aba...@247-inc.com]
Sent: Tuesday, February 18, 2014 5:16 PM
To: user@cassandra.apache.org
Subject: RE: Bootstrap stuck: vnode enabled 1.2.12


I believe you are talking about CASSANDRA-6685, which was introduced in 1.2.15.

I'm trying to add a node to a production ring. I have added nodes previously 
just fine. However, this node had hardware issues during a previous bootstrap, 
and now even a clean bootstrap seems to be having problems. Does the ring 
somehow remember about this node and if so can I make it forget about it? 
Decommission/removenode does not work on a node that hasn't yet bootstrapped.

From: Edward Capriolo [mailto:edlinuxg...@gmail.com]
Sent: Tuesday, February 18, 2014 12:30 PM
To: user@cassandra.apache.org
Subject: Re: Bootstrap stuck: vnode enabled 1.2.12

There is a bug where a node without schema can not bootstrap. Do you have 
schema?

On Tue, Feb 18, 2014 at 1:29 PM, Arindam Barua 
mailto:aba...@247-inc.com>> wrote:

The node is still out of the ring. Any suggestions on how to get it in will be 
very helpful.

From: Arindam Barua [mailto:aba...@247-inc.com]
Sent: Friday, February 14, 2014 1:04 AM
To: user@cassandra.apache.org
Subject: Bootstrap stuck: vnode enabled 1.2.12


After our otherwise successful upgrade procedure to enable vnodes, when adding 
back "new" hosts to our cluster, one non-seed host ran into a hardware issue 
during bootstrap. By the time the hardware issue was fixed a week later, all 
other nodes were added successfully, cleaned, repaired. The disks on this node 
were untouched, and when the node was started back up, it detected an 
interrupted bootstrap, and attempted to bootstrap. However, after ~24 hrs it 
was still stuck in the 'JOINING' state according to nodetool netstats on that 
node, even though no streams were flowing to/from it. Also, it did not appear 
in nodetool status in any way/form (not even as JOINING).

>From couple of observed thread dumps, the stack of the thread blocked during 
>bootstrap is at [1].

Since the node wasn't making any progress, I ended up stopping Cassandra, 
cleaning up the data and commitlog directories, and attempted a fresh 
bootstrap. Nodetool netstats immediately reported a whole bunch of streams 
queued up, and data started streaming to the node. The data directory quickly 
grew to 18 GB (the other nodes had ~25GB, but we have lot of data with low 
TTLs). However, the node ended up being in the earlier reported state, i.e. 
nodetool netstats doesn't have anything queued, but still reports the JOINING 
state, even though it's been > 24 hrs. There are no other ERRORS in the logs, 
and new data being written to the cluster makes it to this node just fine, 
triggering compactions, etc from time to time.

Any help is appreciated.

Thanks,
Arindam
[1] Thread dump
Thread 3708: (state = BLOCKED)
 - sun.misc.Unsafe.park(boolean, long) @bci=0 (Compiled frame; information may
   be imprecise)
 - java.util.concurrent.locks.LockSupport.park(java.lang.Object) @bci=14,
   line=156 (Interpreted frame)
 - java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt()
   @bci=1, line=811 (Interpreted frame)
 -
   
java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(int)
   @bci=55, line=969 (Interpreted frame)
 -
   
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(int)
   @bci=24, line=1281 (Interpreted frame)
 - java.util.concurrent.CountDownLatch.await() @bci=5, line=207 (Interpreted
   frame)
 - org.apache.cassandra.dht.RangeStreamer.fetch() @bci=209, line=256
   (Interpreted frame)
 - org.apache.cassandra.dht.BootStrapper

Re: Cassandra 2.0.5 Configuration

2014-02-24 Thread Robert Coli
On Mon, Feb 24, 2014 at 4:27 PM, Timmy Turner  wrote:

> I already tried setting
>
> log4j.rootLogger=ERROR,stdout,R
>
> it in conf/log4j-server.properties, but that did not seem to have any
> effect.
>

Not sure why this isn't working, but you can set log levels via JMX. Use
something like jconsole or jmxterm.

=Rob


Cassandra Data Model and Surrogate Keys

2014-02-24 Thread John Stager
Hello,

We are working on our data model for Cassandra and we have a need to use
surrogate keys (timeuuid) and not the natural key for one of our tables but
this causes a possible timing issue when determining if a row already
exists.Are there any best practices or patterns for Cassandra for using
surrogate keys?

This is the classic user id (surrogate key) and username (email address).

Thanks

-- 
John W Stager


Re: Cassandra Data Model and Surrogate Keys

2014-02-24 Thread Michael Shuler

On 02/24/2014 09:00 PM, John Stager wrote:

Hello,

We are working on our data model for Cassandra and we have a need to use
surrogate keys (timeuuid) and not the natural key for one of our tables
but this causes a possible timing issue when determining if a row
already exists.Are there any best practices or patterns for Cassandra
for using surrogate keys?

This is the classic user id (surrogate key) and username (email address).


This sounds like the perfect use case for lightweight transactions and 
just using timeuuid. LWT are more expensive due to read before write, 
but when needed, as in your case, it's the right fit. Even with 
perfectly time-synced nodes, there is still a race for two users to 
create the same userid, which is why LWT was included.


http://www.datastax.com/dev/blog/lightweight-transactions-in-cassandra-2-0
http://www.datastax.com/documentation/cassandra/2.0/cassandra/dml/dml_ltwt_transaction_c.html

--
Kind regards,
Michael


Re: Cassandra Data Model and Surrogate Keys

2014-02-24 Thread john . stager
Thanks Michael, I will take a look at LWT for the future but unfortunately we 
are using Cassandra 1.2 ( I should have stated that, sorry). Are there any 
recommendations for 1.2, or do you just have to deal with him the race 
condition and possible duplicate data. 

Thanks again

Sent from my BlackBerry 10 smartphone on the Rogers network.
  Original Message  
From: Michael Shuler
Sent: Monday, February 24, 2014 10:17 PM
To: user@cassandra.apache.org
Reply To: user@cassandra.apache.org
Subject: Re: Cassandra Data Model and Surrogate Keys

On 02/24/2014 09:00 PM, John Stager wrote:
> Hello,
>
> We are working on our data model for Cassandra and we have a need to use
> surrogate keys (timeuuid) and not the natural key for one of our tables
> but this causes a possible timing issue when determining if a row
> already exists.Are there any best practices or patterns for Cassandra
> for using surrogate keys?
>
> This is the classic user id (surrogate key) and username (email address).

This sounds like the perfect use case for lightweight transactions and 
just using timeuuid. LWT are more expensive due to read before write, 
but when needed, as in your case, it's the right fit. Even with 
perfectly time-synced nodes, there is still a race for two users to 
create the same userid, which is why LWT was included.

http://www.datastax.com/dev/blog/lightweight-transactions-in-cassandra-2-0
http://www.datastax.com/documentation/cassandra/2.0/cassandra/dml/dml_ltwt_transaction_c.html

-- 
Kind regards,
Michael


Re: abusing cassandra's multi DC abilities

2014-02-24 Thread Todd Fast
Hi Jonathan--

First, best wishes for success with your platform.

Frankly, I think the architecture you described is only going to cause
you major trouble. I'm left wondering why you don't either use something
like XMPP (of which several implementations can handle this kind of
federated scenario) or simply have internal (REST) APIs to send a message
from the backend in one DC to the backend in another DC.

There are a bunch of ways to approach this problem: You could also use
Redis pubsub (though a bit brittle), SQS, or any number of other approaches
that would be simpler and more robust than what you described. I'd urge you
to really consider another approach.

Best,
Todd

On Saturday, February 22, 2014, Jonathan Haddad  wrote:

> Upfront TLDR: We want to do stuff (reindex documents, bust cache) when
> changed data from DC1 shows up in DC2.
>
> Full Story:
> We're planning on adding data centers throughout the US.  Our platform is
> used for business communications.  Each DC currently utilizes elastic
> search and redis.  A message can be sent from one user to another, and the
> intent is that it would be seen in near-real-time.  This means that 2
> people may be using different data centers, and the messages need to
> propagate from one to the other.
>
> On the plus side, we know we get this with Cassandra (fist pump) but the
> other pieces, not so much.  Even if they did work, there's all sorts of
> race conditions that could pop up from having different pieces of our
> architecture communicating over different channels.  From this, we've
> arrived at the idea that since Cassandra is the authoritative data source,
> we might be able to trigger events in DC2 based on activity coming through
> either the commit log or some other means.  One idea was to use a CF with a
> low gc time as a means of transporting messages between DCs, and watching
> the commit logs for deletes to that CF in order to know when we need to do
> things like reindex a document (or a new document), bust cache, etc.
>  Facebook did something similar with their modifications to MySQL to
> include cache keys in the replication log.
>
> Assuming this is sane, I'd want to avoid having the same event register on
> 3 servers, thus registering 3 items in the queue when only one should be
> there.  So, for any piece of data replicated from the other DC, I'd need a
> way to determine if it was supposed to actually trigger the event or not.
>  (Maybe it looks at the token and determines if the current server falls in
> the token range?)  Or is there a better way?
>
> So, my questions to all ye Cassandra users:
>
> 1. Is this is even sane?
> 2. Is anyone doing it?
>
> --
> Jon Haddad
> http://www.rustyrazorblade.com
> skype: rustyrazorblade
>


Re: Cassandra Data Model and Surrogate Keys

2014-02-24 Thread Michael Shuler

On 02/24/2014 09:24 PM, john.sta...@gmail.com wrote:

Thanks Michael, I will take a look at LWT for the future but
unfortunately we are using Cassandra 1.2 ( I should have stated that,
sorry). Are there any recommendations for 1.2, or do you just have to
deal with him the race condition and possible duplicate data.


I think you would need to try to perform a best effort read before write 
in your application. I guess it depends on the amount of traffic for the 
table. Even then, there is a small race window in that turnaround time. 
A nasty alternative would be a distributed lock manager, or you could 
upgrade to 2.0, if that's possible, which would be easier than messing 
around with locking. Someone may correct me, if there are better 
alternatives. I simple example attached.


Michael
cqlsh> CREATE KEYSPACE users WITH replication = { 'class' : 'SimpleStrategy', 
'replication_factor' : 1 };
cqlsh> CREATE TABLE users.user ( uid text PRIMARY KEY, tid timeuuid, email 
set );
cqlsh> 
cqlsh> SELECT * from users.user ; INSERT INTO users.user ( uid, tid, email ) 
VALUES ( 'bob', now(), {'b...@bob.com'} );

(0 rows)

cqlsh> SELECT * from users.user ; INSERT INTO users.user ( uid, tid, email ) 
VALUES ( 'bob', now(), {'b...@bob.com'} );

 uid | email   | tid
-+-+--
 bob | {'b...@bob.com'} | 7cad2110-9dd6-11e3-a25b-75998baadb41

(1 rows)

cqlsh> SELECT * from users.user ; INSERT INTO users.user ( uid, tid, email ) 
VALUES ( 'bob', now(), {'b...@bob.com'} );

 uid | email   | tid
-+-+--
 bob | {'b...@bob.com'} | 7d177ba0-9dd6-11e3-a25b-75998baadb41

(1 rows)

cqlsh>
cqlsh> SELECT * from users.user ; INSERT INTO users.user ( uid, tid, email ) 
VALUES ( 'bob', now(), {'b...@badbobby.net'} );

 uid | email   | tid
-+-+--
 bob | {'b...@bob.com'} | 7de35720-9dd6-11e3-a25b-75998baadb41

(1 rows)

cqlsh> SELECT * from users.user ;

 uid | email| tid
-+--+--
 bob | {'b...@badbobby.net'} | 8fa89880-9dd6-11e3-a25b-75998baadb41

(1 rows)

cqlsh> 
cqlsh> INSERT INTO users.user ( uid, tid, email ) VALUES ( 'bob', now(), 
{'b...@bob.net'} ) IF NOT EXISTS;
 [applied] | uid | email| tid
---+-+--+--
 False | bob | {'b...@badbobby.net'} | 8fa89880-9dd6-11e3-a25b-75998baadb41

cqlsh>


Re: abusing cassandra's multi DC abilities

2014-02-24 Thread Jonathan Haddad
Thanks for the input Todd.  I've considered a few of the options you've
listed.  I've ruled out redis because it's not really built for multi DC.
 I've got nothing against XMPP, or SQS.  However, they introduce race
conditions as well as all sorts of edge cases (missed messages, for
instance).  Since Cassandra is the source of truth, why not piggyback a
useful message within the "true source of data" itself?




On Mon, Feb 24, 2014 at 8:49 PM, Todd Fast wrote:

> Hi Jonathan--
>
> First, best wishes for success with your platform.
>
> Frankly, I think the architecture you described is only going to cause
> you major trouble. I'm left wondering why you don't either use something
> like XMPP (of which several implementations can handle this kind of
> federated scenario) or simply have internal (REST) APIs to send a message
> from the backend in one DC to the backend in another DC.
>
> There are a bunch of ways to approach this problem: You could also use
> Redis pubsub (though a bit brittle), SQS, or any number of other approaches
> that would be simpler and more robust than what you described. I'd urge you
> to really consider another approach.
>
> Best,
> Todd
>
>
> On Saturday, February 22, 2014, Jonathan Haddad  wrote:
>
>> Upfront TLDR: We want to do stuff (reindex documents, bust cache) when
>> changed data from DC1 shows up in DC2.
>>
>> Full Story:
>> We're planning on adding data centers throughout the US.  Our platform is
>> used for business communications.  Each DC currently utilizes elastic
>> search and redis.  A message can be sent from one user to another, and the
>> intent is that it would be seen in near-real-time.  This means that 2
>> people may be using different data centers, and the messages need to
>> propagate from one to the other.
>>
>> On the plus side, we know we get this with Cassandra (fist pump) but the
>> other pieces, not so much.  Even if they did work, there's all sorts of
>> race conditions that could pop up from having different pieces of our
>> architecture communicating over different channels.  From this, we've
>> arrived at the idea that since Cassandra is the authoritative data source,
>> we might be able to trigger events in DC2 based on activity coming through
>> either the commit log or some other means.  One idea was to use a CF with a
>> low gc time as a means of transporting messages between DCs, and watching
>> the commit logs for deletes to that CF in order to know when we need to do
>> things like reindex a document (or a new document), bust cache, etc.
>>  Facebook did something similar with their modifications to MySQL to
>> include cache keys in the replication log.
>>
>> Assuming this is sane, I'd want to avoid having the same event register
>> on 3 servers, thus registering 3 items in the queue when only one should be
>> there.  So, for any piece of data replicated from the other DC, I'd need a
>> way to determine if it was supposed to actually trigger the event or not.
>>  (Maybe it looks at the token and determines if the current server falls in
>> the token range?)  Or is there a better way?
>>
>> So, my questions to all ye Cassandra users:
>>
>> 1. Is this is even sane?
>> 2. Is anyone doing it?
>>
>> --
>> Jon Haddad
>> http://www.rustyrazorblade.com
>> skype: rustyrazorblade
>>
>


-- 
Jon Haddad
http://www.rustyrazorblade.com
skype: rustyrazorblade


Re: How should clients handle the user defined types in 2.1?

2014-02-24 Thread Theo Hultberg
There hasn't been any activity (apart from my question) since december, and
only sporadic activity before that, so I think it's essentially dead.

http://www.mail-archive.com/client-dev@cassandra.apache.org/

T#


On Mon, Feb 24, 2014 at 10:34 PM, Ben Hood <0x6e6...@gmail.com> wrote:

> On Mon, Feb 24, 2014 at 7:52 PM, Theo Hultberg  wrote:
> > (I posted this on the client-dev list the other day, but that list seems
> > dead so I'm cross posting, sorry if it's the wrong thing to do)
>
> I didn't even realize there was a list for driver implementors - is
> this used at all? Is it worth being on this list?
>


Mixing CAS and TTL.

2014-02-24 Thread J Robert Ray
Hi, I am trying to mix CAS and TTL and am wondering if this behavior that I
am seeing is expected.

I'm on 2.0.2 and using the java datastax 2.0.0-rc3 client.

In my application, a server "claims" a row by assigning a value to a row
using CAS, expecting the column to start out null. The column has a
shortish TTL and while the application "owns" the row, it will periodically
refresh the TTL on the column. If the application dies, the column expires
and can be claimed by another server. My problem is that after the TTL
expires, no server can successfully claim a row using a CAS update.

If I set a TTL on a column with a null value (for demonstration purposes;
the real code sets to a non-null value):

UPDATE foo USING TTL 120 SET col = null WHERE ...;

This CAS update will succeed:

UPDATE foo USING TTL 120 SET col = 'some value' IF col = null; // [applied]
= true
or
UPDATE foo USING TTL 120 SET col = 'some value' IF col = 'foo'; //
[applied] = true, col = null

However, if I allow the TTL to expire, then the same update now fails.

UPDATE foo USING TTL 120 SET col = 'some value' IF col = null; // [applied]
= false

Note, after it fails, the ResultSet column definitions only contains
"[applied]" and so does not provide the value of the 'col' column which
failed the conditional update.

It seems a null value is a different flavor of null than an expired column.
Is it possible to make an update conditional on if a column is expired? Is
this behavior expected or a bug?

Thanks!


RE: Mixing CAS and TTL.

2014-02-24 Thread Daniel Shelepov
For the case where you don't get the update, is your whole row removed when
TTL expires?  If so, you're essentially looking at a non-existing row, and I
think it's not too surprising that a "if col=null" test will behave
differently; I personally wouldn't call it a bug.  If you're dealing with
disappearing rows, you should look into running INSERT IF NOT EXISTS queries
instead of UPDATE IF col=null.

 

If the row is not completely deleted when TTL expires, then the behavior is
definitely fishy, and should probably be filed as a bug.

 

To your other question, once a TTL update is expired, you can't infer its
past existence through any queries.

 

Daniel

 

From: J Robert Ray [mailto:jrobert...@gmail.com] 
Sent: Monday, February 24, 2014 11:10 PM
To: user@cassandra.apache.org
Subject: Mixing CAS and TTL.

 

Hi, I am trying to mix CAS and TTL and am wondering if this behavior that I
am seeing is expected.

 

I'm on 2.0.2 and using the java datastax 2.0.0-rc3 client.

 

In my application, a server "claims" a row by assigning a value to a row
using CAS, expecting the column to start out null. The column has a shortish
TTL and while the application "owns" the row, it will periodically refresh
the TTL on the column. If the application dies, the column expires and can
be claimed by another server. My problem is that after the TTL expires, no
server can successfully claim a row using a CAS update.

 

If I set a TTL on a column with a null value (for demonstration purposes;
the real code sets to a non-null value):

 

UPDATE foo USING TTL 120 SET col = null WHERE ...;

 

This CAS update will succeed:

 

UPDATE foo USING TTL 120 SET col = 'some value' IF col = null; // [applied]
= true

or

UPDATE foo USING TTL 120 SET col = 'some value' IF col = 'foo'; // [applied]
= true, col = null

 

However, if I allow the TTL to expire, then the same update now fails.

 

UPDATE foo USING TTL 120 SET col = 'some value' IF col = null; // [applied]
= false

 

Note, after it fails, the ResultSet column definitions only contains
"[applied]" and so does not provide the value of the 'col' column which
failed the conditional update.

 

It seems a null value is a different flavor of null than an expired column.
Is it possible to make an update conditional on if a column is expired? Is
this behavior expected or a bug?

 

Thanks!