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 10DB9200D06 for ; Mon, 25 Sep 2017 21:09:16 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0F7BE1609BB; Mon, 25 Sep 2017 19:09:16 +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 541BF1609B5 for ; Mon, 25 Sep 2017 21:09:15 +0200 (CEST) Received: (qmail 15863 invoked by uid 500); 25 Sep 2017 19:09: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 15851 invoked by uid 99); 25 Sep 2017 19:09:14 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Sep 2017 19:09:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id B0B4E1A3B36 for ; Mon, 25 Sep 2017 19:09:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.801 X-Spam-Level: X-Spam-Status: No, score=-0.801 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gridgain-com.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id D9E2h0TVQ4GU for ; Mon, 25 Sep 2017 19:09:11 +0000 (UTC) Received: from mail-ua0-f171.google.com (mail-ua0-f171.google.com [209.85.217.171]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id C988A60D08 for ; Mon, 25 Sep 2017 19:09:10 +0000 (UTC) Received: by mail-ua0-f171.google.com with SMTP id g34so5004021uah.7 for ; Mon, 25 Sep 2017 12:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gridgain-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=t1IOrals4L872FJXY7chp3qJmAMnZaUqxBLokwN5gwE=; b=nAJdCpK4V561aWaJ6jQNewcJHXMZVSuPXfxUTRCBPYMmOdN0RLDFW2F+kApbYdSF3l hl/CuQC3d3wXmDyf3bnDh1OECca8FkNvUM+oNtDkL4dp4aj01NrjXP8JdIa3t7gf5uPC Tha+VmcsrkWH/rbRGfmCr1yRor61EkaHiGFx9HfKe+ZI0iHXZH422cU+9wmmp05Ydr69 MLo+mJ+FnAd1Fvfr0uPukPXB+eXjHfXOjOJjek9X5RHu9FsNEg5Ie0/sWCjPhTHeqjkh DUVsjUK7xZABvhIVsxeIf0OrExVKKTEIodGcDomlHk7rzaCFaz2tt3WyJ2G/MbOVZzW6 mbHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=t1IOrals4L872FJXY7chp3qJmAMnZaUqxBLokwN5gwE=; b=OR/RSPTQpVLNBaUEre/34+DIovVTQ3PJFK4/pI7Kd2gzYCQ4S57xV3UHokjs5KdgcS oOxcgEwbROXneJHknlPbOkQ0RSzAhXTlkDzOeqFu/P84q8S2oOq2Uh6+KZQ+p32S6MtA deZfipfmSE2s6HH5uAF+K4am+Y+frCy1qKapEdk8rAUm1+4mXJMCcMis0oOievhKv8Mg UCFasuG7e9i3Q0xqDQy61Vr0CDQFdHNEwvWXFbpDK9UW5vwnaNCK7wHBJeCpB1naCLZ3 qBxHaXajWY0oOA1e6vufCnt3mXhp1YjZ0CAglQ10gG+FtmFk0xWM9hfldyOgG3U/RRmb Pjig== X-Gm-Message-State: AHPjjUg2Ef5tgGILC6hCrDki+mzUTdn2RWNyWJ/4qAz2IKcNKH7JLCd5 Rw8X0kSeb2JyAV2/0FCD9C3NJFOxl2UN//1wb9jzWie6 X-Google-Smtp-Source: AOwi7QBinmxDxi2cFuaGpeDJSDlGaPEw/hoSRWnJv6LH0QmYr0guS9aIO3paOKXGo7wrKI1qRZwFn6y+zsZJsLkmWwk= X-Received: by 10.176.18.98 with SMTP id s34mr8788464uac.166.1506366543666; Mon, 25 Sep 2017 12:09:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.89.193 with HTTP; Mon, 25 Sep 2017 12:09:03 -0700 (PDT) In-Reply-To: References: From: Vladimir Ozerov Date: Mon, 25 Sep 2017 22:09:03 +0300 Message-ID: Subject: Re: Future of Ignite transactions To: dev@ignite.apache.org Content-Type: multipart/alternative; boundary="f403043664a6bcdd94055a084af8" archived-at: Mon, 25 Sep 2017 19:09:16 -0000 --f403043664a6bcdd94055a084af8 Content-Type: text/plain; charset="UTF-8" Folks, Sorry for late reply. I had a chat with several Ignite veterans today. We tried to design transactional SQL for Ignite. One of our questions was how to align SQL transactions with current Ignite transactions. And we failed. And then we came to conclusion that current transaction API is unusable. We have 6 pairs of modes from API standpoint and 4 real modes. This is very counterintuitive and cannot be mapped to any transactional framework our users are familiar with. So we thought how new tx API might looks like, and here is the draft. 1) Define new enum *TransactionIsolationLevel *(to avoid clashes with current enum) with three standard modes - READ_COMMITTED, REPEATABLE_READ, SERIALIZABLE. 2) Define new enum *TransactionHint* - READ_ONLY, OPTIMISTIC_LOCKING 3) No more OPTIMISTIC and PESSIMISTIC. Seriously. 4) Reads never acuire locks 5) Writes always acquire locks 6) *IgniteCache.withReadForUpdate()* will return special facade which will obtain locks on reads. This is analogue of SELECT FOR UPDATE in SQL. 7) *TransactionHint.READ_ONLY* - forces transaction to throw an exception on any update 8) *TransactionHint.OPTIMISTIC_LOCKING* - turns transaction into our current deadlock-free OPTIMISTIC/SERIALIZABLE mode. Applicable only to SERIALIZABLE isolation level. 9) Define new API methods: - IgniteTransactions.txStart(TransactionIsolationLevel isolation) - IgniteTransactions.txStart(TransactionIsolationLevel isolation, TransactionHint... hints) 10) Deprecate old TX start methods As a result we will have simple, clean and extensible API. Which can be explained to users in 5 minutes, instead of current half an hour. And which is perfectly aligned with upcoming transactional SQL. Thoughts? On Thu, Sep 7, 2017 at 6:48 AM, Dmitriy Setrakyan wrote: > Vova, > > Thanks for doing the research. The changes you are suggesting are a bit too > bold, so let's discuss them in some more detail... > > On Wed, Sep 6, 2017 at 4:51 AM, Vladimir Ozerov > wrote: > > > Igniters, > > > > We are moving towards DBMS system. None of them has a notion of > > OPTIMISTIC/PESSIMISTIC transactions. Instead, they work as follows: > > 1) Reads (SELECT) do not acquire exclusive row locks > > 2) Exclusive lock on read could be forced explicitly (SELECT ... FOR > > UPDATE) > > 3) Writes do acuire explicit row locks > > 4) Locks are always acquired immediately once statement is executed > > 5) The strictest concurrency level - typically SERIALIZABLE - rely on > > so-called *range locks* (or *predicate locks*) to track dependencies > > between transactions. Some vendors throw an exception in case of > conflict - > > these are ones where snapshot-based MVCC is used - PostgreSQL, Oracle. > > Others do aggressive locking - ones where two-phase locking algorithm is > > used - SQL Server, MySQL. > > > > As you see, there is no concept of PESSIMISTIC/OPTIMISTIC modes. Instead, > > all updates are "PESSIMISTIC", reads are "OPTIMISTIC" but could become > > "PESSIMISTIC" if requested explicitly, and for snapshot-based vendors (we > > are going in this direction) read-write conflicts are resolved in manner > > somewhat similar to our OPTIMISTIC/SERIALIZABLE. > > > > That said, I would propose to think on how transactions could look like > in > > future Ignite versions (say, 3.0). My rough vision: > > > > 1) No OPTIMISTIC mode at all - too counterintuitive and complex. It's > only > > advantage is deadlock-freedom when combined with SERIALIZABLE. If we have > > good deadlock detector and nice administrative capabilities, this would > not > > be a problem for us. > > > Hm... The advantage of Optimistic Serialiazable mode is actually lock-free > transactions. The deadlock is impossible in this case. I doubt any deadlock > detector would match the performance advantage we get from lock-free > transactions. > > > > > > 2) Behavior of reads could be controlled through "with" facade: > > V val1 = cache.get(key1); // Shared lock or no lock > > V val2 = cache.withForUpdate().get(key2); // Exclusive lock > > > > Don't like the API. We are not trying to abandon the data grid use-case or > API, we are trying to add the database use case. > > > > 3) REPEATABLE_READ - throw exception in case of write-write conflict > > > > Well, I would like to preserve the PESSIMISTIC mode. I find it more > convenient than the "withForUpdate" API. It almost seems like you are > trying to force the pendulum too far in the opposite direction. > > > > 4) SERIALIZABLE - throw exception in case of write-write and write-read > > confilct (this is how our OPTIMISTIC/SERIALZABLE works now, but it > doesn't > > support predicates) > > > > So, no change here? Good :) > > > > 5) Add READ_ONLY isolation mode where updates will not be allowed at all. > > Such transacrtons would be able to bypass some Ignite internals to > achieve > > greater performance, what could be valuable for mostly-read use cases > (e.g. > > OLAP). > > > > Love the idea. We have already seen many use cases that could benefit from > it. > How hard is it to implement? > > > > > > Thoughts? > > > > Vladimir. > > > --f403043664a6bcdd94055a084af8--