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 D56A110776 for ; Mon, 17 Mar 2014 20:06:03 +0000 (UTC) Received: (qmail 83624 invoked by uid 500); 17 Mar 2014 20:06:00 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 83557 invoked by uid 500); 17 Mar 2014 20:06:00 -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 83547 invoked by uid 99); 17 Mar 2014 20:06:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Mar 2014 20:06:00 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_REMOTE_IMAGE X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [66.111.4.25] (HELO out1-smtp.messagingengine.com) (66.111.4.25) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Mar 2014 20:05:56 +0000 Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id CC48220FF6 for ; Mon, 17 Mar 2014 16:05:31 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute3.internal (MEProxy); Mon, 17 Mar 2014 16:05:31 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=venarc.com; h=from :content-type:message-id:mime-version:subject:date:references:to :in-reply-to; s=mesmtp; bh=mTCno6od91DKiXyV+5+y12kC5rs=; b=V9sZp heqMvMXUyaR/8ftplpc5czzaGwmbVoM/gU5wLAodkOWV7ZUXm4mMC9qRwt489DNi tDzGY42s/mU4ETMyDF68NHauKkJqeimlYQo66M2chcg2tO14lgWZoMDl9lGORbYg 1YvjDqStsRPRQz1oSADLyK38Mhp2GGRS0vzTwU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:content-type:message-id:mime-version :subject:date:references:to:in-reply-to; s=smtpout; bh=mTCno6od9 1DKiXyV+5+y12kC5rs=; b=iMCv/JENdd/dJGMCXJRZT0BuxHiM5WX+aj4g//FPz +bhTd977RC5xYN/xO/dITjcqnQ3emZelkupxgCgUT+/ZWdGOVRIL51prHEv02zms iz14lIV/I1pw1WPuvXBcxiXHMFtRuOXQi6eLy8pi1xRymwp1Z0tBoP+iIYVb1h1Y c8= X-Sasl-enc: ECfd2EAp0uLg1ohmZBgJQZ1oe2J7M3iaSmykl6uARfrD 1395086731 Received: from [192.168.77.100] (unknown [76.166.241.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 4505A680138 for ; Mon, 17 Mar 2014 16:05:31 -0400 (EDT) From: Drew Kutcharian Content-Type: multipart/alternative; boundary="Apple-Mail=_1B82F93F-FBCD-40AB-B1FF-ECBF7C8EB923" Message-Id: <38EC5078-8E8A-4177-903C-6EB48C60CD7C@venarc.com> Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: Relation between Atomic Batches and Consistency Level Date: Mon, 17 Mar 2014 13:05:29 -0700 References: <9A3D34AF-88A0-4A37-A585-3FDFB47000B3@venarc.com> <5F37DC9F-B5E6-433D-9095-B0B81B06DA80@venarc.com> To: user@cassandra.apache.org In-Reply-To: X-Mailer: Apple Mail (2.1874) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail=_1B82F93F-FBCD-40AB-B1FF-ECBF7C8EB923 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 I have read that blog post which actually was the source of the initial = confusion ;) If I write normally (no batch) at Quorum, then a hinted write wouldn=92t = count as a valid write so the write wouldn=92t succeed, which means I = would have to retry. That=92s a pretty well defined outcome. Now if I write a logged batch at Quorum, then a by definition, a hinted = write shouldn=92t be considered a valid response, no? - Drew On Mar 17, 2014, at 11:23 AM, Jonathan Lacefield = wrote: > Hello, >=20 > Have you seen this blog post, it's old but still relevant. I think = it will answer your questions. = http://www.datastax.com/dev/blog/atomic-batches-in-cassandra-1-2. >=20 > I think the answer lies in how Cassandra defines a batch "In the = context of a Cassandra batch operation, atomic means that if any of the = batch succeeds, all of it will." >=20 > My understanding is that in your scenario if either statement = succeeded, you batch would succeed. So #1 would get "hinted" and #2 = would be applied, assuming no other failure events occur, like the = coordinator fails, the client fails, etc. >=20 > Hope that helps. >=20 > Thanks, >=20 > Jonathan >=20 > Jonathan Lacefield > Solutions Architect, DataStax > (404) 822 3487 >=20 >=20 >=20 >=20 >=20 >=20 > On Mon, Mar 17, 2014 at 1:38 PM, Drew Kutcharian = wrote: > Hi Jonathan, >=20 > I=92m still a bit unclear on this. Say I have two CQL3 tables: > - user (replication of 3) > - user_email_index (replication of 3) >=20 > Now I create a new logged batch at quorum consistency level and put = two inserts in there: > #1 Insert into the =93user" table with partition key of a timeuuid of = the user=20 > #2 Insert into the =93user_email_index" with partition key of user=92s = email address=20 >=20 > As you can see, there is a chance that these two insert statements = will be executed on two different nodes because they are keyed by = different partition keys. So based on the docs for Logged Batches, a = batch will be applied =93eventually=94 in an "all or nothing=94 fashion. = So my question is, what happens if insert #1 fails (say replicas are = unavailable), would insert #2 get applied? Would the whole thing be = rejected and return an error to the client?=20 >=20 > PS. I=92m aware of the isolation guarantees and that=92s not an issue. = All I need to make sure is that if the first the statement failed, the = whole batch needs to fail. >=20 > Thanks, >=20 > Drew >=20 > On Mar 17, 2014, at 5:33 AM, Jonathan Lacefield = wrote: >=20 >> Hello, >>=20 >> Consistency is declared at the statement level, i.e. batch level = when writing, but enforced at each batch row level. My understanding is = that each batch (and all of it's contents) will be controlled through a = specific CL declaration. So batch A could use a CL of QUORUM while = batch B could use a CL of ONE. =20 >>=20 >> The detail that may help sort this out for you is that batch = statements do not provide isolation guarantees: = www.datastax.com/documentation/cql/3.0/cql/cql_reference/batch_r.html. = This means that you write the batch as a batch but the reads are per = row. If you are reading records contained in the batch, you will read = results of partially updated batches. Taking this into account for your = second question, you should expect that your read CL will preform as it = would for any individual row mutation.=20 >>=20 >> Hope this helps. >>=20 >> Jonathan >>=20 >> Jonathan Lacefield >> Solutions Architect, DataStax >> (404) 822 3487 >>=20 >>=20 >>=20 >>=20 >>=20 >>=20 >> On Sat, Mar 15, 2014 at 12:23 PM, Drew Kutcharian = wrote: >> Hi Guys, >>=20 >> How do Atomic Batches and Consistency Level relate to each other? = More specifically: >>=20 >> - Is consistency level set/applicable per statement in the batch or = the batch as a whole? >>=20 >> - Say if I write a Logged Batch at QUORUM and read it back at QUORUM, = what can I expect at normal, single node replica failure or double node = replica failure scenarios? >>=20 >> Thanks, >>=20 >> Drew >>=20 >=20 >=20 --Apple-Mail=_1B82F93F-FBCD-40AB-B1FF-ECBF7C8EB923 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 I have = read that blog post which actually was the source of the initial = confusion ;)

If I write normally (no batch) at = Quorum, then a hinted write wouldn=92t count as a valid write so the = write wouldn=92t succeed, which means I would have to retry. That=92s a = pretty well defined outcome.

Now if I write a = logged batch at Quorum, then a by definition, a hinted write shouldn=92t = be considered a valid response, no?

- = Drew


On Mar 17, 2014, at 11:23 AM, = Jonathan Lacefield <jlacefield@datastax.com> = wrote:

Hello,

  Have you = seen this blog post, it's old but still relevant.  I think it will = answer your questions.  = http://www.datastax.com/dev/blog/atomic-batches-in-cassandra-1-2.

  I think the answer lies in how Cassandra = defines a batch "In the context of a Cassandra batch operation, atomic means = that if any of the batch succeeds, = all of it will."

  My understanding is = that in your scenario if either statement succeeded, you batch would = succeed.  So #1 would get "hinted" and #2 would be applied, = assuming no other failure events occur, like the coordinator fails, the = client fails, etc.

  Hope that = helps.

Thanks,

Jonathan<= /div>

Jonathan Lacefield
Solutions Architect, DataStax
(404) 822 3487






On Mon, Mar 17, 2014 at 1:38 PM, Drew = Kutcharian <drew@venarc.com> wrote:
Hi Jonathan,

I=92m = still a bit unclear on this. Say I have two CQL3 tables:
- = user (replication of 3)
- user_email_index (replication of = 3)

Now I create a new logged batch at quorum consistency = level and put two inserts in there:
#1 Insert into the =93user" = table with partition key of a timeuuid of the user 
#2 = Insert into the =93user_email_index" with partition key of user=92s = email address 

As you can see, there is a chance that these two = insert statements will be executed on two different nodes because they = are keyed by different partition keys. So based on the docs for Logged = Batches, a batch will be applied =93eventually=94 in an "all or nothing=94= fashion. So my question is, what happens if insert #1 fails (say = replicas are unavailable), would insert #2 get applied? Would the whole = thing be rejected and return an error to the client? 

PS. I=92m aware of the isolation guarantees and = that=92s not an issue. All I need to make sure is that if the first the = statement failed, the whole batch needs to = fail.

Thanks,

Drew

On Mar 17, 2014, at = 5:33 AM, Jonathan Lacefield <jlacefield@datastax.com> = wrote:

Hello,

  Consistency is = declared at the statement level, i.e. batch level when writing, but = enforced at each batch row level.  My understanding is that each = batch (and all of it's contents) will be controlled through a specific = CL declaration.  So batch A could use a CL of QUORUM while batch B = could use a CL of ONE.   

  The detail that may help sort this out for = you is that batch statements do not provide isolation = guarantees: www.datastax.com/documentation/cql/3.0/cql/cql_reference= /batch_r.html.  This means that you write the batch as a batch = but the reads are per row.  If you are reading records contained in = the batch, you will read results of partially updated batches. =  Taking this into account for your second question, you should = expect that your read CL will preform as it would for any individual row = mutation. 

  Hope this = helps.

Jonathan

Jonathan = Lacefield
Solutions Architect, DataStax






On Sat, Mar 15, 2014 at 12:23 PM, = Drew Kutcharian <drew@venarc.com> wrote:
Hi Guys,

How do Atomic Batches and Consistency Level relate to each other? More = specifically:

- Is consistency level set/applicable per statement in the batch or the = batch as a whole?

- Say if I write a Logged Batch at QUORUM and read it back at QUORUM, = what can I expect at normal, single node replica failure or double node = replica failure scenarios?

Thanks,

Drew




= --Apple-Mail=_1B82F93F-FBCD-40AB-B1FF-ECBF7C8EB923--