Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C1DC6200BB8 for ; Sat, 12 Nov 2016 12:26:13 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B56DA160B00; Sat, 12 Nov 2016 11:26:13 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D4874160AF4 for ; Sat, 12 Nov 2016 12:26:12 +0100 (CET) Received: (qmail 13018 invoked by uid 500); 12 Nov 2016 11:26:11 -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 13008 invoked by uid 99); 12 Nov 2016 11:26:11 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Nov 2016 11:26:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id DA15FC0F66 for ; Sat, 12 Nov 2016 11:26:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.63 X-Spam-Level: ** X-Spam-Status: No, score=2.63 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id deH481KLai0O for ; Sat, 12 Nov 2016 11:26:09 +0000 (UTC) Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 6DC9F5F570 for ; Sat, 12 Nov 2016 11:26:08 +0000 (UTC) Received: by mail-wm0-f46.google.com with SMTP id a197so20979926wmd.0 for ; Sat, 12 Nov 2016 03:26:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=lPjQ83YNwZwo+6gtlFNs+jCZGKxi568sq2mNoSmdHhw=; b=BCuxJsLWg1Lo8F/lb0fSp2CcrlWL7temuIFNe1SG9MCss2pu+GfoWqMbO3MF0TiJAS Trg/fIXzCDK9OW/qvYs9miGFz1fsoRNhDdoN30FrD2l/Wn6vQaxHUybkJapl0tetk9x7 17BVSF0ctazAb4zUdjnbGfuS7R7pIAc0Yt00veEfk9OLmv2LlV9CnvTSYUNryItuE+bA 8oqMFrKfz7Cfvp+yzuYNwDa6cJySiEO5bmSTpV/4OfujsAv9HOncFn6m6aeZmuN190BL Nhq8mQzschYKKHQkG+E0kr44Spvq8miGbsx8ILxgyNal7zCGfLoUYeC3Su0qkrRoSD4R IKZg== 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:from:date :message-id:subject:to; bh=lPjQ83YNwZwo+6gtlFNs+jCZGKxi568sq2mNoSmdHhw=; b=DhGHf6HKvJpkkuZZBFRxmgfKV0OdSbjEyCKmYAOIs3RWv39F2jkMq1CxajR30gYTxe Pe789Mq4ruHQoo4eC+pxR56fHTeYcjDmO+utHWGPeqlrfaze8pYtf5ivU4e/DNDekmM4 e2j5ZMbm2PtU2cCaIpX8EvTC6bsxTV1ubgJfdqG4/SLDuwy6WfLzBqJ6StAk0YtwgTp+ 3cVwUwBSy8WfFQ/TMmhJVTmvA9aQ3m5ubh1EST4d/8oMqfMg1M6qWurMqXUZz81kPpxf KAh85AOIyYy/zgSXkXdQ1h3bX+vN2J1x6XXeIdnAVfzspIslhUVxZ3NVt/B18SiRvQYg C5hA== X-Gm-Message-State: ABUngvcjzfDrk0m9r1oC4BmJcg1sC8MKeg+vcKWOi+rPYQ3Jdl08Dx3quCMxblJEreWkEiExColZQBz8RpwASw== X-Received: by 10.194.52.8 with SMTP id p8mr12454996wjo.38.1478949966017; Sat, 12 Nov 2016 03:26:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.50.197 with HTTP; Sat, 12 Nov 2016 03:26:05 -0800 (PST) In-Reply-To: References: <158583659d3.df1e0359422878.4197208065675092815@winguzone.com> From: Ali Akhtar Date: Sat, 12 Nov 2016 16:26:05 +0500 Message-ID: Subject: Re: Consistency when adding data to collections concurrently? To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=047d7b873f805d7e3e054118df8c archived-at: Sat, 12 Nov 2016 11:26:13 -0000 --047d7b873f805d7e3e054118df8c Content-Type: text/plain; charset=UTF-8 I'm responding to a 3rd party API, so I have no control over sending the labels together instead of one by one. In this case, the API will send them one by one. The list is actually of a list> and not a text (I used text for simplification, apologies). In that case, will updates still merge the list values instead of overwriting them? On Sat, Nov 12, 2016 at 4:15 PM, Oskar Kjellin wrote: > Could you not send both labels in one request? Race conditions should > still be handled as Vladimir suggests. But in this specific case the client > could send both as 1 request thus simplifying the solution. > > /Oskar > > On 12 nov. 2016, at 12:05, Vladimir Yudovin wrote: > > Hi Ali, > > >What can I do so I end up with [1, 2] instead of either [1] or [2] after > both requests have been processed? > Use UPDATE, not INSERT. Thus new labels will be added to list, without > overwriting old ones. Also consider usage of SET instead of LIST to avoid > duplicates. > > Best regards, Vladimir Yudovin, > > *Winguzone - Hosted Cloud > CassandraLaunch your cluster in minutes.* > > > ---- On Sat, 12 Nov 2016 05:34:24 -0500*Ali Akhtar >* wrote ---- > > I have a table where each record contains a list of labels. > > I have an endpoint which responds to new labels being added to a record by > the user. > > Consider the following scenario: > > - Record X, labels = [] > - User selects 2 labels, clicks a button, and 2 http requests are > generated. > - The server receives request for Label 1 and Label 2 at the same time. > - Both requests see the labels as empty, add 1 label to the collection, > and send it. > - Record state as label 1 request sees it: [1], as label 2 sees it: [2] > > How will the above conflict be resolved? What can I do so I end up with > [1, 2] instead of either [1] or [2] after both requests have been processed? > > > --047d7b873f805d7e3e054118df8c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I'm responding to a 3rd party API, so I have no contro= l over sending the labels together instead of one by one. In this case, the= API will send them one by one.

The list is actually of = a list<frozen<my_udt>> and not a text (I used text for simplifi= cation, apologies).

In that case, will updates sti= ll merge the list values instead of overwriting them?

On Sat, Nov 12, 2016 at 4:1= 5 PM, Oskar Kjellin <oskar.kjellin@gmail.com> wrote:
Could you not send = both labels in one request? Race conditions should still be handled as Vlad= imir suggests. But in this specific case the client could send both as 1 re= quest thus simplifying the solution.=C2=A0
/Oskar

On 12 nov. 2016= , at 12:05, Vladimir Yudovin <vladyu@winguzone.com> wrote:

Hi Ali,

>What c= an I do so I end up with [1, 2] instead of either [1] or [2] after both req= uests have been processed?
Use UPDATE, not INSERT. Thus new l= abels will be added to list, without overwriting old ones. Also consider us= age of SET instead of LIST to avoid duplicates.=C2=A0

Best regards, Vladimir Yudovin,=
Winguzone - Hosted Cloud Cassandra
Launch your cluster in mi= nutes.


---- On = Sat, 12 Nov 2016 05:34:24 -0500Ali Akhtar <ali.rac200@gmail.com> wrote ----=

I have= a table where each record contains a list<string> of labels.

I have an endpoint which responds to new labels being= added to a record by the user.

Consider the f= ollowing scenario:

- Record X, labels =3D []
- User selects 2 labels, clicks a button, and 2 http requests = are generated.
- The server receives request for Label 1 and = Label 2 at the same time.
- Both requests see the labels as e= mpty, add 1 label to the collection, and send it.
- Record st= ate as label 1 request sees it: [1], as label 2 sees it: [2]
=
How will the above conflict be resolved? What can I do so I = end up with [1, 2] instead of either [1] or [2] after both requests have be= en processed?

=

--047d7b873f805d7e3e054118df8c--