Return-Path: Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: (qmail 59538 invoked from network); 14 Mar 2010 22:30:53 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 14 Mar 2010 22:30:53 -0000 Received: (qmail 66816 invoked by uid 500); 14 Mar 2010 22:30:08 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 66732 invoked by uid 500); 14 Mar 2010 22:30:08 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 66724 invoked by uid 99); 14 Mar 2010 22:30:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Mar 2010 22:30:08 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of frewstore@gmail.com designates 209.85.211.203 as permitted sender) Received: from [209.85.211.203] (HELO mail-yw0-f203.google.com) (209.85.211.203) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Mar 2010 22:30:02 +0000 Received: by ywh41 with SMTP id 41so143498ywh.9 for ; Sun, 14 Mar 2010 15:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=r7BshKgk4tQjNbNw7IiulpRSxs+TGTTOg9lrFa5wTPg=; b=JDgGXPTavskkW67RxUdCN+f3xxVKR0M2liIYrB44VN7sjI1gtnHZy8SS8OAdc5CejZ ZjdUR97GDwAlkU+vGJ33f8OPZVNrIbx+0zvc9RPHpIrDT8T3Q0a2GlfmuafopdUsP9Gy YRI7s1ng8lQ4YBWfL+m0nf4AD1MRNc8qH/wLA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=QYk3LD2qGpKjvzWwb9cmVuN4jXXAe7fRVwnFsoVBV4dXzs7OhRsXr3ETOAv0sDnyDo ngqSQuI7G6U5eZ6Pi2h7WluvzwcOOwWRhOpZkC4cAdit/Jh6krUfNK1KRr/CKxN9aGcr Y2UxcbXbIhJGJkpPuZ8Hh4lkJzLCvLdHotVIk= MIME-Version: 1.0 Sender: frewstore@gmail.com Received: by 10.91.50.29 with SMTP id c29mr1798981agk.82.1268605781224; Sun, 14 Mar 2010 15:29:41 -0700 (PDT) In-Reply-To: References: Date: Sun, 14 Mar 2010 15:29:41 -0700 X-Google-Sender-Auth: 61a576e420095684 Message-ID: <2e191f541003141529v6a194f3dif5060420178f6ff2@mail.gmail.com> Subject: Re: serialized vector clock as global counter? From: Fred Wulff To: user@cassandra.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hey Toby, I'm not an expert on Cassandra's infrastructure, but I believe the thing the AppEngine datastore has that Cassandra doesn't is a transaction between the read and write of a sharded counter. That means that while the read of the various counters may be inconsistent, the actual update of the shard is always consistent and the read of that shard is always consistent with the previous write. -Fred On Sun, Mar 14, 2010 at 9:46 AM, Toby DiPasquale wrote: > Hi all, > > I'm trying to write an application using Cassandra which requires the > use of a global, monotonically-increasing counter. I've seen the > previous threads on this subject which basically say that this can't > be done in Cassandra as is, but I think I've come up with a method > that might work. I wanted to get the list's feedback on whether or not > this method is workable: > > * Each client maintains its own monotonically-increasing counter as a > row in Cassandra > * When a client wants to increment the counter, it will: > =A0* increment its own counter key using a quorum write > =A0* read all keys in the CF using a quorum read > =A0* the sum of the values is then the value of the counter > > This method is robust against nodes coming and going (new nodes just > get a new counter and dead nodes never increase their counter again). > It also doesn't matter for my application if some possible values for > the counter are skipped over, as long as every value is greater than > the last. I believe this scheme to be commensurate to a vector clock, > no? > > My question would be: assuming we're using both quorum reads and > writes, is it possible that clients A and B could race in the > following manner: > > * A updates its counter > * B updates its counter > * A reads the keys to get sum X > * B reads the keys to get the same sum X > > ...thus violating the ever-increasing constraint? > > Google App Engine suggests a similar method for doing global counters > on Datastore: http://code.google.com/appengine/articles/sharding_counters= .html. > I'm troubled by their implementation, though, because the reads on the > list of counters are not transactional and are potentially subject to > the same race that I've described above. > > Any thoughts/ideas? > > -- > Toby DiPasquale >