Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 639707478 for ; Sun, 13 Nov 2011 02:41:40 +0000 (UTC) Received: (qmail 90045 invoked by uid 500); 13 Nov 2011 02:41:38 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 89979 invoked by uid 500); 13 Nov 2011 02:41:38 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 89971 invoked by uid 99); 13 Nov 2011 02:41:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Nov 2011 02:41:37 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [74.125.82.44] (HELO mail-ww0-f44.google.com) (74.125.82.44) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Nov 2011 02:41:30 +0000 Received: by wwe5 with SMTP id 5so2288814wwe.25 for ; Sat, 12 Nov 2011 18:41:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.134.18 with SMTP id r18mr3141363wei.40.1321152069773; Sat, 12 Nov 2011 18:41:09 -0800 (PST) Received: by 10.216.73.65 with HTTP; Sat, 12 Nov 2011 18:41:09 -0800 (PST) In-Reply-To: <4EBF0865.6000600@gmail.com> References: <4EBC2754.2080700@gmail.com> <4EBF0865.6000600@gmail.com> Date: Sat, 12 Nov 2011 18:41:09 -0800 Message-ID: Subject: Re: indexes from CassandraSF From: Ed Anuff 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 1) The index updates should be eventually consistent. This does mean that you can get a transient false-positive on your search results. If this doesn't work for you, then you either need to use ZK or some other locking solution or do "read repair" by making sure that the row you retrieve contains the value you're searching for before passing it on to the rest of your applicaiton. 2) You should be able to reapply the batch updates til they succeed. The update is idempotent. One thing that's important that the slides don't make clear is that this requires using time-based uuids as your timestamp components. Take a look at the sample code. Hope this helps, Ed On Sat, Nov 12, 2011 at 3:59 PM, Guy Incognito wrote: > help? > > On 10/11/2011 19:34, Guy Incognito wrote: >> >> hi, >> >> i've been looking at the model below from Ed Anuff's presentation at >> Cassandra CF (http://www.slideshare.net/edanuff/indexing-in-cassandra). >> =A0Couple of questions: >> >> 1) Isn't there still the chance that two concurrent updates may end up >> with the index containing two entries for the given user, only one of wh= ich >> would be match the actual value in the Users cf? >> >> 2) What happens if your batch fails partway through the update? =A0If i >> understand correctly there are no guarantees about ordering when a batch= is >> executed, so isn't it possible that eg the previous >> value entries in Users_Index_Entries may have been deleted, and then the >> batch fails before the entries in Indexes are deleted, ie the mechanism = has >> 'lost' those values? =A0I assume this can be addressed >> by not deleting the old entries until the batch has succeeded (ie put th= e >> previous entry deletion into a separate, subsequent batch). =A0this at l= east >> lets you retry at a later time. >> >> perhaps i'm missing something? >> >> SELECT {"location"}..{"location", *} >> FROM Users_Index_Entries WHERE KEY =3D ; >> >> BEGIN BATCH >> >> DELETE {"location", ts1}, {"location", ts2}, ... >> FROM Users_Index_Entries WHERE KEY =3D ; >> >> DELETE {, , ts1}, {, , ts2}, ... >> FROM Indexes WHERE KEY =3D "Users_By_Location"; >> >> UPDATE Users_Index_Entries SET {"location", ts3} =3D >> WHERE KEY=3D; >> >> UPDATE Indexes SET {, , ts3) =3D null >> WHERE KEY =3D "Users_By_Location"; >> >> UPDATE Users SET location =3D >> WHERE KEY =3D ; >> >> APPLY BATCH >> > >