Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jgSpO-0006fb-Nt for pgsql-bugs@arkaria.postgresql.org; Wed, 03 Jun 2020 12:49:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jgSpN-0004zd-Eq for pgsql-bugs@arkaria.postgresql.org; Wed, 03 Jun 2020 12:49:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jgSpN-0004zV-28 for pgsql-bugs@lists.postgresql.org; Wed, 03 Jun 2020 12:49:05 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jgSpI-00005e-DZ for pgsql-bugs@lists.postgresql.org; Wed, 03 Jun 2020 12:49:04 +0000 Received: by mail-qk1-x736.google.com with SMTP id f18so1959887qkh.1 for ; Wed, 03 Jun 2020 05:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jepsen-io.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=5gu/LFNbkb3xZA3iooNllxhFR17NFAA0+B8gMbVKRLA=; b=bOW6YUXxXW7+dcS4yeMV5gkSymUH8pvWNLm5OrG8r/hHGEfNGoNszHnpwDi2psu4xO ckQfEeM30Cz0ALF37qEgmjZ8kUojNRZTitH6wdhqL8La45ViYn04IfYFAWphbzhR9Sr4 1BtzvxYZx/ovXnsTOyBYx0tcJ0rheDMHQZMG18lmtQQe3VHyME1KEKjs2gmonGmXUuO7 3l0hJRkH4cqWtcgk3l2HfaQvIPI+sV63glGuEkNyK1Rz2ginqNgSb4hYiRv9HLuXdcp2 aBxy8Uv2E7YnMWHzFp+RRl05mEIM0Rf/5Mbk+LmI3mKUt40A3kAoEio6ATrL2R489WfK /dww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=5gu/LFNbkb3xZA3iooNllxhFR17NFAA0+B8gMbVKRLA=; b=ApnlNC0iLLxz5fKUc9zfk1OKW9NGYIMwa4wSYqFYhoWzmM3CrqYwH9JbijJXV3OK7k CaPXfRxzO1gG9rfQBfsDUOzzb2ixTf6IWzeaoqyZku+BnkJz2GdKMynCPjgyMo0rSp9F yzBWgJZoYRavt2/b+IuZRDYv0OaKOqVMBW9jyrZ6Oq3ekpU/vYIm1ZsZuXQ+EbLWac4I DeiWmmmZTAF1F5WzjPiyfAYytFNKaG0JusmQCIeT0IqedH/VI052RJ2V/6cjQRzcJpwP e4CibP98xyz5nB9351yQyk1UTMx7mwpW0kbO6og6yXqfSR21Jp6dH3sCWeNvhTenNohk KxLg== X-Gm-Message-State: AOAM532g9ZwH4JWHEOwwRuNuiM0xqejNFpgVNj5UUsSs+R0cN0Uxameq mH8YSjOjDUsF6f6yHhPWb4xQxi5sPrU= X-Google-Smtp-Source: ABdhPJx7TIAYobZ9VJn9GP5z29BGypGE0edlliIQIxIBpYQlaFWbV0kdDVQ+oCFP1DAcoJAnlPjRUg== X-Received: by 2002:a37:b847:: with SMTP id i68mr28817927qkf.431.1591188537905; Wed, 03 Jun 2020 05:48:57 -0700 (PDT) Received: from ?IPv6:2600:2b00:9454:af00:e2d0:928:2474:ec45? ([2600:2b00:9454:af00:e2d0:928:2474:ec45]) by smtp.gmail.com with ESMTPSA id v69sm1438582qkb.96.2020.06.03.05.48.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Jun 2020 05:48:57 -0700 (PDT) Subject: Re: Potential G2-item cycles under serializable isolation To: Daniel Verite Cc: PostgreSQL mailing lists References: <6e4c7e1d-e901-4e84-bf37-66b58d0cf8d3@manitou-mail.org> From: Kyle Kingsbury Message-ID: <3b27aff9-b8ce-6ded-7eed-4d208b3a26d2@jepsen.io> Date: Wed, 3 Jun 2020 08:48:56 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <6e4c7e1d-e901-4e84-bf37-66b58d0cf8d3@manitou-mail.org> Content-Type: multipart/alternative; boundary="------------A958E3BE354757CDCE005A44" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------A958E3BE354757CDCE005A44 Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit On 6/3/20 7:51 AM, Daniel Verite wrote: > But it doesn't say that the *only* difference between RR and > Serializable is avoiding P3. When defining P1, P2, P3, it doesn't > explicitly say that these are the only anomalies that can arise from > concurrency. Ah, yes, now I understand. I've been working with Berenson/Adya too long--I've taken their conclusions for granted. You're right: the spec comes awfully close, but doesn't say these are the *only* phenomena possible: > The following phenomena are possible: [description of P1, P2, and > P3] > The isolation levels are different with respect to phenomena P1, P2, > and P3. Berenson et al., in "A Critique of ANSI SQL Isolation Levels", identified this as a key challenge in interpreting the spec: > The isolation levels are defined by the phenomena they are forbidden > to experience. But also: > The prominence of the table compared to this extra proviso leads to > a common misconception that disallowing the three phenomena implies > serializability. Which led Berenson et al. to claim that the SQL spec's definitions are a.) ambiguous and b.) incomplete. They argue that the "strict" (or, in Adya, the "anomaly") interpretation is incorrect, and construct a "broad" (Adya: "preventative") interpretation in terms of a new phenomenon (P0: dirty writes), and more general forms of P1, P2, and P3. The bulk of section 3 demonstrates that the anomaly interpretations lead to weird results, and that what the ANSI spec *intended* was the preventative interpretations. > Strict interpretations A1, A2, and A3 have unintended weaknesses. > The correct interpretations are the Broad ones. We assume in what > follows that ANSI meant to define P1, P2, and P3. For a more concise overview of this, see Adya's thesis, section 2.3. Adya goes on to show that the preventative interpretation forbids some serializable histories, and redefines the ANSI levels again in terms of generalized, MVCC-friendly phenomena G0, G1, and G2. When I say Postgres violates repeatable read, I mean in the sense that it allows G2-item, which is prevented by Adya PL-2.99: repeatable read. See Adya 3.2.4 for his formulation of repeatable read, which *does* differ from serializability only in terms of predicate-related phenomena. http://pmg.csail.mit.edu/papers/adya-phd.pdf For a compact version of this argument and formalism, see Adya, Liskov, & O'Neil's "Generalized Isolation Level Definitions": http://bnrg.cs.berkeley.edu/~adj/cs262/papers/icde00.pdf. That's why I was asking a few days ago whether Postgres had adopted the anomaly interpretation--Since Postgres implements SI, it made sense that y'all would have followed Berenson et al. in using the preventative interpretation, or Adya in using generalized definitions. But... in the Postgres docs, and your comments in this thread, it seems like y'all are going with the anomaly interpretation instead. That'd explain why there's this extra "serialization anomaly" difference between RR and serializable. That'd also explain why the Postgres docs imply RR << SI, even though Berenson et al. and Adya both say RR >><< SI. Is... that the right way to understand things? --Kyle --------------A958E3BE354757CDCE005A44 Content-Type: text/html; charset=iso-8859-15 Content-Transfer-Encoding: 7bit On 6/3/20 7:51 AM, Daniel Verite wrote:
> But it doesn't say that the *only* difference between RR and > Serializable is avoiding P3. When defining P1, P2, P3, it doesn't > explicitly say that these are the only anomalies that can arise from > concurrency.
Ah, yes, now I understand. I've been working with Berenson/Adya too long--I've taken their conclusions for granted. You're right: the spec comes awfully close, but doesn't say these are the *only* phenomena possible:

> The following phenomena are possible: [description of P1, P2, and > P3] > The isolation levels are different with respect to phenomena P1, P2, > and P3.
Berenson et al., in "A Critique of ANSI SQL Isolation Levels", identified this as a key challenge in interpreting the spec:

> The isolation levels are defined by the phenomena they are forbidden > to experience.
But also:

> The prominence of the table compared to this extra proviso leads to > a common misconception that disallowing the three phenomena implies > serializability.
Which led Berenson et al. to claim that the SQL spec's definitions are a.) ambiguous and b.) incomplete. They argue that the "strict" (or, in Adya, the "anomaly") interpretation is incorrect, and construct a "broad" (Adya: "preventative") interpretation in terms of a new phenomenon (P0: dirty writes), and more general forms of P1, P2, and P3. The bulk of section 3 demonstrates that the anomaly interpretations lead to weird results, and that what the ANSI spec *intended* was the preventative interpretations.

> Strict interpretations A1, A2, and A3 have unintended weaknesses. > The correct interpretations are the Broad ones. We assume in what > follows that ANSI meant to define P1, P2, and P3.

For a more concise overview of this, see Adya's thesis, section 2.3. Adya goes on to show that the preventative interpretation forbids some serializable histories, and redefines the ANSI levels again in terms of generalized, MVCC-friendly phenomena G0, G1, and G2. When I say Postgres violates repeatable read, I mean in the sense that it allows G2-item, which is prevented by Adya PL-2.99: repeatable read. See Adya 3.2.4 for his formulation of repeatable read, which *does* differ from serializability only in terms of predicate-related phenomena.

http://pmg.csail.mit.edu/papers/adya-phd.pdf

For a compact version of this argument and formalism, see Adya, Liskov, & O'Neil's "Generalized Isolation Level Definitions": http://bnrg.cs.berkeley.edu/~adj/cs262/papers/icde00.pdf.

That's why I was asking a few days ago whether Postgres had adopted the anomaly interpretation--Since Postgres implements SI, it made sense that y'all would have followed Berenson et al. in using the preventative interpretation, or Adya in using generalized definitions. But... in the Postgres docs, and your comments in this thread, it seems like y'all are going with the anomaly interpretation instead. That'd explain why there's this extra "serialization anomaly" difference between RR and serializable. That'd also explain why the Postgres docs imply RR << SI, even though Berenson et al. and Adya both say RR >><< SI.

Is... that the right way to understand things?

--Kyle

--------------A958E3BE354757CDCE005A44--