Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y5kgJ-0005DZ-Dc for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Dec 2014 00:29:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y5kgI-0008Sp-5B for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Dec 2014 00:29:02 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5kg8-0008B2-0P for pgsql-hackers@postgresql.org; Tue, 30 Dec 2014 00:28:52 +0000 Received: from mail-by2on0620.outbound.protection.outlook.com ([2a01:111:f400:fc0c::620] helo=na01-by2-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y5kg3-00022S-55 for pgsql-hackers@postgresql.org; Tue, 30 Dec 2014 00:28:49 +0000 Received: from decina.local (24.55.12.91) by CY1PR11MB0348.namprd11.prod.outlook.com (25.161.165.16) with Microsoft SMTP Server (TLS) id 15.1.49.12; Tue, 30 Dec 2014 00:28:40 +0000 Message-ID: <54A1F1B1.40002@BlueTreble.com> Date: Mon, 29 Dec 2014 18:28:33 -0600 From: Jim Nasby User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Kevin Grittner , Merlin Moncure , Greg Stark CC: Tom Lane , Josh Berkus , "nikita.y.volkov@mail.ru" , "pgsql-hackers@postgresql.org" Subject: Re: BUG #12330: ACID is broken for unique constraints References: <1511100927.1386218.1419872004754.JavaMail.yahoo@jws100113.mail.ne1.yahoo.com> In-Reply-To: <1511100927.1386218.1419872004754.JavaMail.yahoo@jws100113.mail.ne1.yahoo.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [24.55.12.91] X-ClientProxiedBy: BLUPR08CA0065.namprd08.prod.outlook.com (10.141.200.45) To CY1PR11MB0348.namprd11.prod.outlook.com (25.161.165.16) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jim.Nasby@bluetreble.com; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:CY1PR11MB0348; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:CY1PR11MB0348; X-Forefront-PRVS: 04410E544A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(479174004)(189002)(24454002)(377454003)(65816999)(20776003)(54356999)(87976001)(2950100001)(105586002)(97736003)(50986999)(68736005)(36756003)(62966003)(101416001)(31966008)(2171001)(106356001)(19580395003)(23676002)(64706001)(46102003)(40100003)(99396003)(15975445007)(64126003)(4396001)(122386002)(21056001)(76176999)(83506001)(120916001)(77156002)(107046002)(92566001)(86362001)(42186005)(47776003)(65956001)(19580405001)(65806001)(66066001)(50466002)(33656002)(85282002)(336755003)(18886065003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR11MB0348; H:decina.local; FPR:; SPF:None; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: bluetreble.com does not designate permitted sender hosts) X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:CY1PR11MB0348; X-OriginatorOrg: bluetreble.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Dec 2014 00:28:40.1616 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR11MB0348 X-Pg-Spam-Score: -1.9 (-) 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 On 12/29/14, 10:53 AM, Kevin Grittner wrote: > Merlin Moncure wrote: > >> Serialization errors only exist as a concession to concurrency >> and performance. Again, they should be returned as sparsely as >> possible because they provide absolutely (as Tom pointed >> out) zero detail to the application. > > That is false. They provide an *extremely* valuable piece of > information which is not currently available when you get a > duplicate key error -- whether the error occurred because of a race > condition and will not fail for the same cause if retried. As for missing details like the duplicated key value, is there a reasonable way to add that as an errdetail() to a serialization failure error? We do still have to be careful here though; you could still have code using our documented upsert methodology inside a serialized transaction. For example, via a 3rd party extension that can't assume you're using serialized transactions. Would it still be OK to treat that as a serialization failure and bubble that all the way back to the application? As part of this, we should probably modify our upsert example so it takes transaction_isolation into account... > As for the fact that RI violations also don't return a > serialization failure when caused by a race with concurrent > transactions, I view that as another weakness in PostgreSQL. I > don't think there is a problem curing one without curing the other > at the same time. I have known of people writing their own > triggers to enforce RI rather than defining FKs precisely so that > they can get a serialization failure return code and do automatic > retry if it is caused by a race condition. That's less practical > to compensate for when it comes to unique indexes or constraints. Wow, that's horrible. :( -- Jim Nasby, Data Architect, Blue Treble Consulting Data in Trouble? Get it in Treble! http://BlueTreble.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers