On 04/08/2010 04:53 AM, Philip Jackson wrote:
At Wed, 07 Apr 2010 13:19:26 -0700,
Mike Gallamore wrote:
I have writes to cassandra that are failing, or at least a read shortly
after a write is still getting an old value. I realize Cassandra is
"eventually consistent" but this system is a single CPU single node with
consistency level set to 1, so this seems odd to me.
I'm having this problem too (see my post the other day). I use N::C
but generate timestamps in the same way as N::C::E, I've tested that
each is smaller than the next so I'm wondering if I'm barking up the
wrong tree.

If you figure out what's going on please do post back here, I'll do
the same.

Cheers,
Phil
Hello. If you are doing exactly the same thing as N::C::Easy (ie a join on the gettimeofday). Then you should have the same problem I found a fix for. The problem is that the microseconds value isn't zero padded. So if you are at say 23s 25 micro seconds you get a date: 2325. not 23000025 which of course means that sometimes your next timestamp will be "older" than your previous one. Here is a patch to N::C::Easy that fixes this and hopefully a similar thing will fix your code.


diff -ru Net-Cassandra-Easy-0.09/lib/Net/Cassandra/Easy.pm 
Net-Cassandra-Easy-0.09-patched/lib/Net/Cassandra/Easy.pm
--- Net-Cassandra-Easy-0.09/lib/Net/Cassandra/Easy.pm   2010-04-06 
13:03:59.000000000 -0700
+++ Net-Cassandra-Easy-0.09-patched/lib/Net/Cassandra/Easy.pm   2010-04-08 
11:29:39.000000000 -0700
@@ -40,7 +40,11 @@
 has recv_buffer  => ( is => 'ro', isa => 'Int',     default => 1024 );
 has send_buffer  => ( is => 'ro', isa => 'Int',     default => 1024 );
 has max_results  => ( is => 'ro', isa => 'Int',     default => 100 );
-has timestamp    => ( is => 'ro', isa => 'CodeRef', default => sub { sub { 
join('', gettimeofday()) } } );
+has timestamp    => ( is => 'ro', isa => 'CodeRef', default => sub { 
+        sub {
+            my ($secs, $usecs) = gettimeofday();
+            return $secs . sprintf "%0.6d", $usecs;
+        } } );
 
 # read and write consistency can be changed on the fly
 has read_consistency  => ( is => 'rw', isa => 'Int', default => 
Net::GenCassandra::ConsistencyLevel::ONE );

Reply via email to