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 EA12410FC4 for ; Wed, 5 Mar 2014 10:03:41 +0000 (UTC) Received: (qmail 81243 invoked by uid 500); 5 Mar 2014 10:03:38 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 80890 invoked by uid 500); 5 Mar 2014 10:03:37 -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 80882 invoked by uid 99); 5 Mar 2014 10:03:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Mar 2014 10:03:35 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sylvain@datastax.com designates 209.85.160.43 as permitted sender) Received: from [209.85.160.43] (HELO mail-pb0-f43.google.com) (209.85.160.43) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Mar 2014 10:03:29 +0000 Received: by mail-pb0-f43.google.com with SMTP id um1so872114pbc.30 for ; Wed, 05 Mar 2014 02:03:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=jEU/SkpqIY48XnUb3iqWjn+JpknF1JV7INC5n2Iw9dY=; b=NLQActPJQjnhasz/Kej+Q1ON5pKNx2uIKI8wBYGkqgCK9ORTNHVIm9cgiZMi1RPDrW jCGYwmO+kxQedpYQAlEAt2uMQozJ0pQeDSwVLkO5KMW+kif/Q5uFJkSxBpFZUeAL9m+R 7mm0xqAiXTI/bJ7Vy7MqAg0v5n0AcAlGSojd1lE44NRahVMu//lkGHFn+mdGu4DhX/TX 0+DqsoCA3laOCzzP2+xKDlGXgpNWk+iWAALYBkgrg2hH39eWlbMTGaN/Dx9L1ZpZY8lO gvdmiguQP7/kydrZ7kUVmM4W63bDV/F4fzc8EibmGNcgzoWWkBeDwptf/utD3rnDgHbE CjCQ== X-Gm-Message-State: ALoCoQkyvyTxESzfo9h4tTgL9KvFzihFgr2MMFRD1adDSJVOgo1qVusMO9+olz1/NUVL1N+pj7xj MIME-Version: 1.0 X-Received: by 10.68.164.4 with SMTP id ym4mr5774947pbb.53.1394013787748; Wed, 05 Mar 2014 02:03:07 -0800 (PST) Received: by 10.68.39.136 with HTTP; Wed, 5 Mar 2014 02:03:07 -0800 (PST) In-Reply-To: <8D1BD6A2-D023-4179-8B7C-7B7BBC1D77C8@expedia.com> References: <8D1BD6A2-D023-4179-8B7C-7B7BBC1D77C8@expedia.com> Date: Wed, 5 Mar 2014 11:03:07 +0100 Message-ID: Subject: Re: Question regarding java DowngradingConsistencyRetryPolicy From: Sylvain Lebresne To: "user@cassandra.apache.org" Content-Type: multipart/alternative; boundary=047d7b5d3610a1927604f3d9206b X-Virus-Checked: Checked by ClamAV on apache.org --047d7b5d3610a1927604f3d9206b Content-Type: text/plain; charset=ISO-8859-1 Let me first note that the DataStax Java driver has a dedicated mailing list: https://groups.google.com/a/lists.datastax.com/forum/#!forum/java-driver-user, it would better to use that list for driver specific questions in the future. But to answer your question, a SIMPLE write is any write (INSERT, UPDATE, DELETE) that is not in a batch. Concretely, if you do: session.execute("INSERT INTO ..."); it's a SIMPLE write. -- Sylvain On Tue, Mar 4, 2014 at 7:21 PM, HAITHEM JARRAYA wrote: > Hi All, > > I might be missing something and I would like some clarification on this. > We are using the java driver with the Downgrading Retry policy, we see in > our logs that are only the reads are retried. > > In the code and the docs, it says that the write method will retry a > maximum of one retry, when the WriteType is UNLOGGED_BATCH or BATCH_LOG. > My question is, when a write is considered as SIMPLE? > > Thanks, > > Haithem > > /** > * Defines whether to retry and at which consistency level on a write > timeout. > *

> * This method triggers a maximum of one retry. If {@code writeType == > * WriteType.BATCH_LOG}, the write is retried with the initial > * consistency level. If {@code writeType == WriteType.UNLOGGED_BATCH} > * and at least one replica acknowledged, the write is retried with a > * lower consistency level (with unlogged batch, a write timeout can > * always mean that part of the batch haven't been persisted at > * all, even if {@code receivedAcks > 0}). For other {@code writeType}, > * if we know the write has been persisted on at least one replica, we > * ignore the exception. Otherwise, an exception is thrown. > * > * @param statement the original query that timed out. > * @param cl the original consistency level of the write that timed > out. > * @param writeType the type of the write that timed out. > * @param requiredAcks the number of acknowledgments that were > required to > * achieve the requested consistency level. > * @param receivedAcks the number of acknowledgments that had been > received > * by the time the timeout exception was raised. > * @param nbRetry the number of retry already performed for this > operation. > * @return a RetryDecision as defined above. > */ > @Override > public RetryDecision onWriteTimeout(Statement statement, > ConsistencyLevel cl, WriteType writeType, int requiredAcks, int > receivedAcks, int nbRetry) { > if (nbRetry != 0) > return RetryDecision.rethrow(); > > switch (writeType) { > case SIMPLE: > case BATCH: > // Since we provide atomicity there is no point in retrying > return RetryDecision.ignore(); > case UNLOGGED_BATCH: > // Since only part of the batch could have been persisted, > // retry with whatever consistency should allow to persist > all > return maxLikelyToWorkCL(receivedAcks); > case BATCH_LOG: > return RetryDecision.retry(cl); > } > // We want to rethrow on COUNTER and CAS, because in those case > "we don't know" and don't want to guess > return RetryDecision.rethrow(); > } > > > --047d7b5d3610a1927604f3d9206b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Let me first note that the DataStax Java driver has a dedi= cated mailing list:=A0https://groups.google.com/a/lists.data= stax.com/forum/#!forum/java-driver-user, it would better to use that li= st for driver specific questions in the future.

But to answer your question, a SIMPLE write is any write (IN= SERT, UPDATE, DELETE) that is not in a batch. Concretely, if you do:
<= div>=A0 session.execute("INSERT INTO ...");
it's a = SIMPLE write.

--
Sylvain


On Tue, Mar 4, 2014 at 7:21 PM, HAIT= HEM JARRAYA <a-hjarraya@expedia.com> wrote:
Hi All,

I might be missing something and I would like some clarification on this. W= e are using the java driver with the Downgrading Retry policy, we see in ou= r logs that are only the reads are retried.

In the code and the docs, it says that the write method will retry a maximu= m of one retry, when the WriteType is UNLOGGED_BATCH or BATCH_LOG.
My question is, when a write is considered as SIMPLE?

Thanks,

Haithem

=A0 =A0 /**
=A0 =A0 =A0* Defines whether to retry and at which consistency level on a w= rite timeout.
=A0 =A0 =A0* <p>
=A0 =A0 =A0* This method triggers a maximum of one retry. If {@code writeTy= pe =3D=3D
=A0 =A0 =A0* WriteType.BATCH_LOG}, the write is retried with the initial =A0 =A0 =A0* consistency level. If {@code writeType =3D=3D WriteType.UNLOGG= ED_BATCH}
=A0 =A0 =A0* and at least one replica acknowledged, the write is retried wi= th a
=A0 =A0 =A0* lower consistency level (with unlogged batch, a write timeout = can
=A0 =A0 =A0* <b>always</b> mean that part of the batch haven= 9;t been persisted at
=A0 =A0 =A0* all, even if {@code receivedAcks > 0}). For other {@code wr= iteType},
=A0 =A0 =A0* if we know the write has been persisted on at least one replic= a, we
=A0 =A0 =A0* ignore the exception. Otherwise, an exception is thrown.
=A0 =A0 =A0*
=A0 =A0 =A0* @param statement the original query that timed out.
=A0 =A0 =A0* @param cl the original consistency level of the write that tim= ed out.
=A0 =A0 =A0* @param writeType the type of the write that timed out.
=A0 =A0 =A0* @param requiredAcks the number of acknowledgments that were re= quired to
=A0 =A0 =A0* achieve the requested consistency level.
=A0 =A0 =A0* @param receivedAcks the number of acknowledgments that had bee= n received
=A0 =A0 =A0* by the time the timeout exception was raised.
=A0 =A0 =A0* @param nbRetry the number of retry already performed for this = operation.
=A0 =A0 =A0* @return a RetryDecision as defined above.
=A0 =A0 =A0*/
=A0 =A0 @Override
=A0 =A0 public RetryDecision onWriteTimeout(Statement statement, Consistenc= yLevel cl, WriteType writeType, int requiredAcks, int receivedAcks, int nbR= etry) {
=A0 =A0 =A0 =A0 if (nbRetry !=3D 0)
=A0 =A0 =A0 =A0 =A0 =A0 return RetryDecision.rethrow();

=A0 =A0 =A0 =A0 switch (writeType) {
=A0 =A0 =A0 =A0 =A0 =A0 case SIMPLE:
=A0 =A0 =A0 =A0 =A0 =A0 case BATCH:
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Since we provide atomicity there is no p= oint in retrying
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return RetryDecision.ignore();
=A0 =A0 =A0 =A0 =A0 =A0 case UNLOGGED_BATCH:
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // Since only part of the batch could have = been persisted,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // retry with whatever consistency should a= llow to persist all
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return maxLikelyToWorkCL(receivedAcks);
=A0 =A0 =A0 =A0 =A0 =A0 case BATCH_LOG:
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return RetryDecision.retry(cl);
=A0 =A0 =A0 =A0 }
=A0 =A0 =A0 =A0 // We want to rethrow on COUNTER and CAS, because in those = case "we don't know" and don't want to guess
=A0 =A0 =A0 =A0 return RetryDecision.rethrow();
=A0 =A0 }



--047d7b5d3610a1927604f3d9206b--