Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YYZTL-0004mt-2x for pgsql-bugs@arkaria.postgresql.org; Thu, 19 Mar 2015 12:22:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YYZTK-0007e1-DF for pgsql-bugs@arkaria.postgresql.org; Thu, 19 Mar 2015 12:22:46 +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 1YYZTJ-0007dv-Hi for pgsql-bugs@postgresql.org; Thu, 19 Mar 2015 12:22:45 +0000 Received: from nm20-vm3.bullet.mail.ne1.yahoo.com ([98.138.91.150]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YYZTE-0002D5-Dz for pgsql-bugs@postgresql.org; Thu, 19 Mar 2015 12:22:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s2048; t=1426767757; bh=YqfPjyd1OFqS6+11DJeGTVOEe0ie3mYwprvDRf6mfqE=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=mAJBoy0//NdifWc44XN+X2ZnTtkgnvzVORRx1oFdWH9yzmevqa2vnMVxGDdxUEUfK48Vv28b3SIiEez1983CUBqJt9R7zSsEAeVX+Hcqx+xdiNxnbecHLBp+4OoyW3jSrb3O18z+zLAbzHH0jkCBwRvctHfR1z7/1uP4YzOsZJq7sHeLfXfDsYB5I5hTRntxS7pBq4DTJTbZrRRsdEQfdicC/asNVVhMMTDJHstAy9R0rOnLYLSDjOizJHTbSWZUaWuk4GhGZfmpG/FkKrqH0ET/nRU6dbTOaoPygbMqvD5gK5LOrbUAnEz6uar57MTg3Z9yjq0MySHW3kldImF5eQ== Received: from [98.138.100.113] by nm20.bullet.mail.ne1.yahoo.com with NNFMP; 19 Mar 2015 12:22:37 -0000 Received: from [98.138.89.165] by tm104.bullet.mail.ne1.yahoo.com with NNFMP; 19 Mar 2015 12:22:37 -0000 Received: from [127.0.0.1] by omp1021.mail.ne1.yahoo.com with NNFMP; 19 Mar 2015 12:22:37 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 339142.63481.bm@omp1021.mail.ne1.yahoo.com X-YMail-OSG: g_ibaEIVM1m02dA3isW1EnZStjk_RmccaHW6dFMegrivMn30UXjcy6NjI69r.my 5OIMt1MEa2l9GcTdl3ABSBr10IN2bdLHN6R88ZL4pELissNR1EECna.q6NiwOxnBaBI7pOofLxce 8YhFbhmmEDO1GVL3Kd7ow_KMtyPA6xe7gtEJ2Qy3Cob0GrszxV31LXUBC2witw4I33dJovIj78OG uzKldOjM6WCIX.LcalErm.PmvfX7h4zj3.uQGPRF2HhdjZWEMg2A1P9yvLZWbMXEl6_HdIOHm8Sr ZVgFEpNo9XxJZAdooSAaQr0ySRO.Zpx82O_fyXCSNDFcuvey4bZMX42W47Kf7su0QT_HTSkddUnA kfzSY.VTYlS3hdgDateP82HmoV6A6AXfLwgfSpUdM9qSZ_7cHedLtoGeeJ3hPpJxUEY6GeMXhNtw CH6WXnjgZr0RgxDlS0c2HqRdVVCN4Ur7iHhoD6xgR_8TKX_GP0POPCREPf3Cs6WuRC4Fj12q5cta suskDwXbnI7p18VDmLyaTw0kFfVMOoaQHid3JprRXpAz630glrDnDmyZX5Tj01.qKMP9eg4sDmIJ Zw_kREzScTwAwlOmdc6NkqdawcsxZFjH2u1Wostl45aQawsvKak0pgMJv96ZC3.JsiwKGCxClhr. ci59pQQ-- Received: by 98.138.105.219; Thu, 19 Mar 2015 12:22:36 +0000 Date: Thu, 19 Mar 2015 12:22:35 +0000 (UTC) From: Kevin Grittner Reply-To: Kevin Grittner To: Hursh Jain , "pgsql-bugs@postgresql.org" Message-ID: <153754345.412294.1426767755926.JavaMail.yahoo@mail.yahoo.com> In-Reply-To: <550A2400.8090201@beesell.com> References: <550A2400.8090201@beesell.com> Subject: Re: postgres 9.3.6, serialize error with two independent, serially consistent transactions.. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 2609 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hursh Jain wrote: > In the example below, client #1 and client #2 are not doing > anything that can possibly cause a inconsistent serial order of > execution. You can pick and choose whichever one you want to run > first, the final result will be 100% consistent and exactly the > same, either way. > > So why does postgres 9.3.6 give an error to the second client ? > Unless I am reading this docs wrong, this looks like a major bug. This is not a bug. What use of serializable transactions guarantees is that the behavior of any set of successfully committed serializable transactions is consistent with some serial order of execution of those transactions. If you retry the second transaction (which got the serialization failure) it will succeed and you have behavior consistent with either order of execution, so the conditions are met. There is no guarantee that there will be no false positives (where a serialization failure is generated where with infinite time and resources to analyze everything it could have been avoided). Note that if you add a primary key on the id column, and use values that do not cause duplicate keys, you do not get any error. Without an index a full table scan is needed, which causes a predicate lock which has a rw-conflict with any insert to the table. Two transactions doing this concurrently will cause a serialization failure. If we tracked enough information to avoid this case, resource usage and performance would not be in a range most would consider acceptable; heuristics are needed, which inevitably allows false positives in some circumstances. If you try your example on any database which uses strict two phase locking (S2PL) to implement serializable transactions (e.g., MS SQL Server, DB2, MySQL, Berkeley DB, etc.), I think you will find that you also get a false positive serialization failure in the form of a deadlock. In databases which do not actually provide serializable behavior when you ask for it (e.g., Oracle), you will not get an error. If you want that level of transaction isolation in PostgreSQL you can request REPEATABLE READ, and you will likewise not get an error. For a description of the differences between these isolation levels see the docs: http://www.postgresql.org/docs/current/interactive/mvcc.html For some examples of cases where you get different results between these two isolation levels, see: https://wiki.postgresql.org/wiki/SSI PostgreSQL gives you a choice of which behavior you prefer. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs