Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 0645A64FCD2 for ; Wed, 23 Jul 2008 18:26:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 94212-06 for ; Wed, 23 Jul 2008 18:26:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id AD26F64FCCC for ; Wed, 23 Jul 2008 18:26:52 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m6NLQnaK013240; Wed, 23 Jul 2008 17:26:50 -0400 (EDT) To: Alvaro Herrera cc: Teodor Sigaev , Pgsql Hackers Subject: Re: [PATCHES] GIN improvements In-reply-to: <20080723204430.GD3580@alvh.no-ip.org> References: <483FD205.4090904@sigaev.ru> <486BC501.6060605@sigaev.ru> <27880.1215810535@sss.pgh.pa.us> <487A6E0C.3090600@sigaev.ru> <8993.1216843701@sss.pgh.pa.us> <20080723204430.GD3580@alvh.no-ip.org> Comments: In-reply-to Alvaro Herrera message dated "Wed, 23 Jul 2008 16:44:30 -0400" Date: Wed, 23 Jul 2008 17:26:49 -0400 Message-ID: <13239.1216848409@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200807/1100 X-Sequence-Number: 121360 Alvaro Herrera writes: > Tom Lane wrote: >> It's a mess: > These are rather severe problems. Maybe there's a better solution, but > perhaps it would be good enough to lock out concurrent access to the > index while the bulkinsert procedure is working. Ugh... The idea I was toying with was to not allow GIN scans to "stop" on pending-insertion pages; rather, they should suck out all the matching tuple IDs into backend-local memory as fast as they can, and then return the TIDs to the caller one at a time from that internal array. Then, when the scan is later visiting the main part of the index, it could check each matching TID against that array to see if it'd already returned the TID. (So it might be an idea to sort the TID array after gathering it, to make those subsequent checks fast via binary search.) This would cost in backend-local memory, of course, but hopefully not very much. The advantages are the elimination of the deadlock risk from scan-blocks-insertcleanup-blocks-insert, and fixing the race condition when a TID previously seen in the pending list is moved to the main index. There were still a number of locking issues to fix but I think they're all relatively easy to deal with. regards, tom lane