Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TMOf3-0002Vo-48 for pgsql-hackers@postgresql.org; Thu, 11 Oct 2012 19:43:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TMOf0-0006N7-OP for pgsql-hackers@postgresql.org; Thu, 11 Oct 2012 19:43:12 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q9BJh4a7025608; Thu, 11 Oct 2012 15:43:04 -0400 (EDT) From: Tom Lane To: Robert Haas cc: Simon Riggs , Tomas Vondra , Thom Brown , pgsql-hackers@postgresql.org Subject: Re: change in LOCK behavior In-reply-to: References: <5075D8DF.6050500@fuzzy.cz> <5075DFC2.9090306@fuzzy.cz> <12761.1349910622@sss.pgh.pa.us> <14951.1349916214@sss.pgh.pa.us> <19901.1349974420@sss.pgh.pa.us> <21922.1349976162@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Thu, 11 Oct 2012 15:25:29 -0400" Date: Thu, 11 Oct 2012 15:43:04 -0400 Message-ID: <25607.1349984584@sss.pgh.pa.us> X-Pg-Spam-Score: -4.0 (----) X-Archive-Number: 201210/607 X-Sequence-Number: 214843 Robert Haas writes: > So we have to take the snapshot before you begin execution, but it > seems that to avoid surprising behavior we also have to take it after > acquiring locks. And it looks like locking is intertwined with a > bunch of other parse analysis tasks that might require a snapshot to > have been taken first. Whee. Yeah. I think that a good solution to this would involve guaranteeing that the execution snapshot is not taken until we have all locks that are going to be taken on the tables. Which is likely to involve a fair amount of refactoring, though I admit I've not looked at details. In any case, it's a mistake to think about this in isolation. If we're going to do something about redefining SnapshotNow to avoid its race conditions, that's going to move the goalposts quite a lot. Anyway, my feeling about it is that I don't want 9.2 to have an intermediate behavior between the historical one and whatever we end up designing to satisfy these concerns. That's why I'm pressing for reversion and not a band-aid fix in 9.2. I certainly hope we can do better going forward, but this is not looking like whatever we come up with would be sane to back-patch. regards, tom lane