From dev-return-37011-archive-asf-public=cust-asf.ponee.io@ignite.apache.org Thu Jul 26 13:25:16 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id A85C6180621 for ; Thu, 26 Jul 2018 13:25:15 +0200 (CEST) Received: (qmail 21633 invoked by uid 500); 26 Jul 2018 11:25:14 -0000 Mailing-List: contact dev-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list dev@ignite.apache.org Received: (qmail 21621 invoked by uid 99); 26 Jul 2018 11:25:14 -0000 Received: from mail-relay.apache.org (HELO mailrelay1-lw-us.apache.org) (207.244.88.152) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jul 2018 11:25:14 +0000 Received: from mail-io0-f179.google.com (mail-io0-f179.google.com [209.85.223.179]) by mailrelay1-lw-us.apache.org (ASF Mail Server at mailrelay1-lw-us.apache.org) with ESMTPSA id BE7751376 for ; Thu, 26 Jul 2018 11:25:13 +0000 (UTC) Received: by mail-io0-f179.google.com with SMTP id g11-v6so1034929ioq.9 for ; Thu, 26 Jul 2018 04:25:13 -0700 (PDT) X-Gm-Message-State: AOUpUlGuLI8xH+y/W921ABvR8C8NyiOjh8K/0SI4hpKre9MJi+MISqMG Fo5dFw2RsIwesaN6HWMZkBPS0sYtaLPTEDaz1mk= X-Google-Smtp-Source: AAOMgpfwTvHnKAJHksP/1RjEdwsdeVruYT82gh9+cZ/01Fu1bW0k/PUhLDGvGRljGwy/BMeW2h9nztkNjCJq5Aq7cYY= X-Received: by 2002:a6b:4006:: with SMTP id k6-v6mr1063273ioa.277.1532604313112; Thu, 26 Jul 2018 04:25:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Anton Vinogradov Date: Thu, 26 Jul 2018 14:25:02 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Dirty Reads and READ_COMMITTED To: dev@ignite.apache.org Content-Type: multipart/alternative; boundary="000000000000aa158f0571e53f59" --000000000000aa158f0571e53f59 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi all, Let's initially agree we're discussing about PESSIMISTIC, since OPTIMISTIC provides no warranty on read before it commited. Also, we should have some reproducer to make sure we're discussing same issue. I guess it's possible to have dirty reads only in following case - first transaction commiting now under writelocks (I hope we acquire them (all) before firs write, and release (all) after last write) - second transaction does not acquire readlocks and just reads what can anyway, in case we have some issues here, it should be easy to write a reproducer. Or we already have tests covers isolation issues? =D1=87=D1=82, 26 =D0=B8=D1=8E=D0=BB. 2018 =D0=B3. =D0=B2 1:58, Dmitriy Setr= akyan : > Let's suppose that some transaction is trying to update values A and B: > > *tx.start() * > > > > > > *cache.put("A", 1);cache.put("B", 2); * > > > > *tx. commit();* > > > If you use READ_COMMITTED isolation level, it is possible that you will > read the new value of A and the old value of B. If you need to make sure > that you read the new values for A and B, then you need to use > REPEATABLE_READ transaction in PESSIMISTIC mode. Note, that you can also > use OPTIMISTIC SERIALIZABLE transactions as well, but in this case if you > run into a conflict, then the transaction will be rolled back. > > D. > > On Wed, Jul 25, 2018 at 11:19 PM, Valentin Kulichenko < > valentin.kulichenko@gmail.com> wrote: > > > I believe Ignite updates values during the commit phase, so it's not > > possible to get a dirty read even if you do not acquire distributed loc= ks > > on reads with READ_COMMITTED isolation. But I would let other community > > members who are more knowledgeable in this topic to add there comments, > as > > it's possible that I'm missing something. > > > > As for documentation, looks like semantic of "lock" there always implie= s > > that it is help until transaction is committed or rolled back. Probably > it > > makes sense to clarify this as well. > > > > And yes, please disregard the REPEATABLE_READ point. I misread you > initial > > message a little bit. > > > > -Val > > > > On Wed, Jul 25, 2018 at 11:25 AM John Wilson > > wrote: > > > > > And no. I'm not describing REPEATABLE_READ. I'm describing > > > https://en.wikipedia.org/wiki/Isolation_(database_systems)#Dirty_read= s > > and > > > how READ_COMMITTED isolation can avoid dirty reads. > > > > > > On Wed, Jul 25, 2018 at 11:20 AM, John Wilson > > > > wrote: > > > > > > > I agree with your description. But the documentation https:// > > > > apacheignite.readme.io/docs/transactions is misleading in stating > that > > > no > > > > read locks are acquired (says "READ_COMMITTED - Data is read withou= t > a > > > lock > > > > and is never cached in the transaction itself."). Which should be > > wrong. > > > > Read locks are acquired but they are released as soon as the read i= s > > > > complete (and they are not held until the transaction commits or > rolls > > > > back). > > > > > > > > Thanks, > > > > > > > > On Wed, Jul 25, 2018 at 10:33 AM, Valentin Kulichenko < > > > > valentin.kulichenko@gmail.com> wrote: > > > > > > > >> Hi John, > > > >> > > > >> Read committed isolation typically implies that lock on read is no= t > > held > > > >> throughout the transaction lifecycle, i.e. released right after re= ad > > is > > > >> completed (in Ignite this just means that no lock is required at > all). > > > >> This > > > >> semantic allows second read to get an updated value that was alrea= dy > > > >> committed by another transaction. See Wikipedia description for > > example: > > > >> > > > https://en.wikipedia.org/wiki/Isolation_(database_systems)# > > Read_committed > > > >> > > > >> What you're describing is REPEATABLE_READ isolation which guarante= es > > > that > > > >> subsequent reads return the same value. In Ignite it's achieved by > > > >> acquiring lock on read and releasing it only on commit/rollback. > > > >> > > > >> -Val > > > >> > > > >> On Wed, Jul 25, 2018 at 10:12 AM John Wilson < > sami.hailu.15@gmail.com > > > > > > >> wrote: > > > >> > > > >> > Hi, > > > >> > > > > >> > Consider the following transaction where we read key 1 twice. > > > >> > > > > >> > try (Transaction tx =3D Ignition.ignite().transactions > > > >> ().txStart(PESSIMISTIC, > > > >> > READ_COMMITTED)) { > > > >> > cache.get(1); > > > >> > //... > > > >> > cache.get(1); > > > >> > tx.commit(); > > > >> > } > > > >> > > > > >> > According to the documentation here, > > > >> > https://apacheignite.readme.io/docs/transactions, data is read > > > without > > > >> a > > > >> > lock and is never cached. If that is the case, then how do we > avoid > > a > > > >> dirty > > > >> > read on the second cache.get(1)? Another uncommitted transaction > may > > > >> update > > > >> > the key between the first and second reads. > > > >> > > > > >> > In most RDMS, a READ_COMMITTED isolation level, acquires locks f= or > > > both > > > >> > read and writes. The read lock is released after a read while th= e > > > write > > > >> > lock is held until the transaction completes. So for the above > > > example, > > > >> I > > > >> > expect a read lock on each cache.get(1). > > > >> > > > > >> > > > > >> > Thanks, > > > >> > > > > >> > > > > > > > > > > > > > > --000000000000aa158f0571e53f59--