X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8497AD1E9CA for ; Sun, 2 May 2004 11:31:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 16942-09 for ; Sun, 2 May 2004 11:30:47 -0300 (ADT) Received: from mailhost2.tudelft.nl (mailhost2.tudelft.nl [130.161.180.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4DF17D1EDE3 for ; Sun, 2 May 2004 11:30:43 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by rav.antivirus (Postfix) with ESMTP id 827C430C84; Sun, 2 May 2004 16:30:47 +0200 (MEST) Received: from listserv.tudelft.nl (listserv.tudelft.nl [130.161.180.33]) by mailhost2.tudelft.nl (Postfix) with ESMTP id 5819530C7E; Sun, 2 May 2004 16:30:47 +0200 (MEST) Received: from oli.tudelft.nl (www@secure.oli.tudelft.nl [130.161.180.141]) by listserv.tudelft.nl (8.12.10/8.12.8) with SMTP id i42EUkF7016249; Sun, 2 May 2004 16:30:47 +0200 (MEST) Received: from 130.161.199.221 (SquirrelMail authenticated user jochemd@oli.tudelft.nl) by secure.oli.tudelft.nl with HTTP; Sun, 2 May 2004 16:30:47 +0200 (CEST) Message-ID: <1529.130.161.199.221.1083508247.squirrel@secure.oli.tudelft.nl> Date: Sun, 2 May 2004 16:30:47 +0200 (CEST) Subject: Re: planner/optimizer question From: "Jochem van Dieten" To: In-Reply-To: References: <409290F0.10509@oli.tudelft.nl> <8881.1083374379@sss.pgh.pa.us> <4093876C.2060409@oli.tudelft.nl> X-Priority: 3 Importance: Normal Cc: , X-Mailer: SquirrelMail (version 1.2.10) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at tudelft.nl X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/9 X-Sequence-Number: 6840 Manfred Koizar said: > > As Tom has explained in a nearby message his concern is that -- > unlike dead-to-all -- visible-to-all starts as false, is set to true > at some point in time, and is eventually set to false again. > Problems arise if one backend wants to set visible-to-all to true > while at the same time another backend wants to set it to false. Got it, I misinterpreted his concern as "visible-to-all should not be set to true when the tuple is inserted". > This could be curable by using a second bit as a deleted flag (might > be even the same bit that's now used as dead-to-all, but I'm not > sure). An index tuple having both the visible flag (formerly called > visible-to-all) and the deleted flag set would cause a heap tuple > access to check visibility. Or in a more generalized way: with 2 bits written at the same time you can express 4 states. But only 3 actions need to be signalled: dead-to-all, visible-to-all and check-heap. So we can have 2 states that both signal check-heap. The immediate solution to the race condition Tom presented would be to have the transaction that invalidates the heap tuple switch the index tuple from the one check-heap state to the other. The transaction that wants to update to visible-to-all can now see that the state has changed (but not the meaning) and aborts its change. > But that leaves the question of what to > do after the deleting transaction has rolled back. I see no clean > way from the visible-and-deleted state to visible-to-all. I'm afraid I don't know enough about the inner workings of rollbacks to determine how the scenario "A determines visible-to-all should be set, B invalidates tuple, B rolls back, C invalidates tuple, C commits, A reaquires lock on index" would work out. I guess I have some more reading to do. But if you don't roll back too often it wouldn't even be a huge problem to just leave them in visible-and-deleted state until eventually they go into the dead-to-all state. Jochem