Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y5av9-000765-H8 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2014 14:03:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y5av7-0005Gb-Cw for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2014 14:03:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5av4-0005GS-6f for pgsql-hackers@postgresql.org; Mon, 29 Dec 2014 14:03:39 +0000 Received: from nm27.bullet.mail.ne1.yahoo.com ([98.138.90.90]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Y5auz-0003HC-Eh for pgsql-hackers@postgresql.org; Mon, 29 Dec 2014 14:03:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s2048; t=1419861809; bh=AgUzDWTxlCk/ea4VRc7yhQUn1fvO7X6EoYItTqcwmcE=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=acLO/Eid1VVuO66XRqKHhEPWGl1yNgUcee28xiwjilZGLLL+hKqB3GKv6FOx3RI3roLXBZoeY1y/qnKtHPYl7EwiFNs+KkJkdxBv7LScjLQeg0ckcFu+M/0nJsyy4FuSU3rk5B8cPeN2YWGXQkpJug0H+ta73Bo0ZAht5ZYon6z0gogcQ81uijS8AfJ+ScWYmdcwXMkylGeIocYCQzvVbPDzSJLBOQQxjmWKjTnpQiB+ndLVB20uhXfW5YN2134CStrEYlR3aPZRDFp1cL0jh5hYs0QzJnArkApK9L0xGjx4hSu0/j4H/AokPSMyZCucGtcdLjR0/qo7U6L70irxPw== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=ymail.com; b=RQTWD57AFVuP37ojyh9yAN+OlFc2F467nQT7f+KFAtflYEmu153hcFlSVJxUCMZFEqsZdVq4qj+HpaXbE/+jWK8Vy+BSimCERDFSof1wTJMhg81j8BNezC9adQSAjLaIZWIyhkmceSXq1nMtzzbzgYzJHYbJq6wo/szcEZxYH5ARZYc78V/l0YzbXrvk5USZ4LqzzhQH4Xb5Y7aulvWI+57b8D2usZxs1ZuurHeKtLNLHkGd+4eLJEY+W+ePHHu4SjJiOHDSY3seWMNRy89sLlhoBb+gmLmzDBmg5zzLsXhWz1iiB3DGMFV6LYe/29TmWrFDQTdBnM2ebSC/neN+OQ==; Received: from [98.138.100.113] by nm27.bullet.mail.ne1.yahoo.com with NNFMP; 29 Dec 2014 14:03:29 -0000 Received: from [98.138.87.9] by tm104.bullet.mail.ne1.yahoo.com with NNFMP; 29 Dec 2014 14:03:29 -0000 Received: from [127.0.0.1] by omp1009.mail.ne1.yahoo.com with NNFMP; 29 Dec 2014 14:03:29 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 918389.55730.bm@omp1009.mail.ne1.yahoo.com X-YMail-OSG: O05jqYgVM1msj6ooNgPAsbCRV5PfYZUEWe_wOrQ6fYTg.hVO4m2yb4wAKtDHEWA D4Nl7ieYVoW4EQykXtu3x2ADNo4nrlMDbhzqoqhliSOlTtSB321x3CgDQaFuITQaoixsPPIpBsB8 Vaq6PBE7XVmMkt5V9_uDecQnZMJ45TWCX_gyAzv0SlNiOWTB8V8YQeS5FuVoGseB_addZf4PNEt1 Xi7Iysb7WazRfpLT_lPO9CwEwQKeu66_FcLcqGF7S59CcDXgZ.D3rzPYJ0MSHYRHfIkv17BSG3Ur ARr5u3RGvCj9aexF16qqNbBubizdVi7.3sAq4spOLOi9rFUGWqUnxs3GrRdf_NgRCdi..JmyXat. 89aGhCaJV2cJL8mnCc_OcOEE28Gj34GUdRQfiMsj3m.cUhifuhX0KL1m3UNVhEYaQMhxr0QrY.cm _UMk6pB6E_sXFbZPibmMzZuyMPWQNNHnafYtzlBe8HcSu6y3aPD4BNgLYFp.Udijo_Zy0y8Vm6K. dbgUhopDcbDmQiEXHxIzpB.Mo1moAFm6nyVLJzj8HmfNPNUz4HF6cSNom30.0vA-- Received: by 98.138.105.248; Mon, 29 Dec 2014 14:03:29 +0000 Date: Mon, 29 Dec 2014 14:03:28 +0000 (UTC) From: Kevin Grittner Reply-To: Kevin Grittner To: Merlin Moncure Cc: Tom Lane , Josh Berkus , "nikita.y.volkov@mail.ru" , "pgsql-hackers@postgresql.org" Message-ID: <1956080374.1363800.1419861808211.JavaMail.yahoo@jws100109.mail.ne1.yahoo.com> In-Reply-To: References: Subject: Re: BUG #12330: ACID is broken for unique constraints MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1363799_481357400.1419861808207" Content-Length: 7440 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org ------=_Part_1363799_481357400.1419861808207 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Merlin Moncure wrote: > On Fri, Dec 26, 2014 at 12:38 PM, Kevin Grittner wrot= e: >> Tom Lane wrote: >> >>> Just for starters, a 40XXX error report will fail to provide the >>> duplicated key's value.=C2=A0 This will be a functional regression, >> >> Not if, as is normally the case, the transaction is retried from >> the beginning on a serialization failure.=C2=A0 Either the code will >> check for a duplicate (as in the case of the OP on this thread) and >> they won't see the error, *or* the the transaction which created >> the duplicate key will have committed before the start of the retry >> and you will get the duplicate key error. > > I'm not buying that; that argument assumes duplicate key errors are > always 'upsert' driven.=C2=A0 Although OP's code may have checked for > duplicates it's perfectly reasonable (and in many cases preferable) to > force the transaction to fail and report the error directly back to > the application.=C2=A0 The application will then switch on the error code > and decide what to do: retry for deadlock/serialization or abort for > data integrity error.=C2=A0 IOW, the error handling semantics are > fundamentally different and should not be mixed. I think you might be agreeing with me without realizing it.=C2=A0 Right=20 now you get "duplicate key error" even if the duplication is caused=20 by a concurrent transaction -- it is not possible to check the=20 error code (well, SQLSTATE, technically) to determine whether this=20 is fundamentally a serialization problem.=C2=A0 What we're talking about=20 is returning the serialization failure return code for the cases=20 where it is a concurrent transaction causing the failure and=20 continuing to return the duplicate key error for all other cases. Either I'm not understanding what you wrote above, or you seem to be arguing for being able to distinguish between errors caused by concurrent transactions and those which aren't. -- Kevin GrittnerEDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company ------=_Part_1363799_481357400.1419861808207 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Merlin Moncure <m= moncure@gmail.com> wrote:
> On Fri, Dec 26, 2014 at 12:38 PM, Kevin Grittner <kgrittn@ym= ail.com> wrote:
>= ;> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>>> Just for starters, a 40XXX error report will fail= to provide the
>&g= t;> duplicated key's value.  This will be a functional regression,<= br class=3D"yiv4165093533" style=3D"" clear=3D"none">>>
>> Not if, as is normally the= case, the transaction is retried from
>> the beginning on a serialization failure.  E= ither the code will
&g= t;> check for a duplicate (as in the case of the OP on this thread) and<= br class=3D"yiv4165093533" style=3D"" clear=3D"none">>> they won't se= e the error, *or* the the transaction which created
>> the duplicate key will have committe= d before the start of the retry
>> and you will get the duplicate key error.
>
> I'm not buying that; that argument assumes dupli= cate key errors are
&g= t; always 'upsert' driven.  Although OP's code may have checked for> duplicates it's per= fectly reasonable (and in many cases preferable) to
> force the transaction to fail and report= the error directly back to
> the application.  The application will then switch on the e= rror code
> and dec= ide what to do: retry for deadlock/serialization or abort for
> data integrity error.  IO= W, the error handling semantics are
> fundamentally different and should not be mixed.

I think you might be agreeing with me without real= izing it.  Right
now you get "duplicate key error" even if the duplication is caused
by a concurrent transaction= -- it is not possible to check the
error code (well, SQLSTATE, technically) to determine whethe= r this
is fundamental= ly a serialization problem.  What we're talking about
is returning the serialization failur= e return code for the cases
where it is a concurrent transaction causing the failure and
continuing to return the dup= licate key error for all other cases.

Eithe= r I'm not understanding what you wrote above, or you seem to
be arguing for being able to disting= uish between errors caused by
concurrent transactions and those which aren't.



--
Kevin GrittnerEDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


------=_Part_1363799_481357400.1419861808207--