Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aOX8g-0002TR-Q5 for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Jan 2016 20:56:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aOX8f-0005j4-Ce for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Jan 2016 20:56:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aOX7J-0004BM-UV for pgsql-hackers@postgresql.org; Wed, 27 Jan 2016 20:55:05 +0000 Received: from mimolette.dalibo.net ([212.85.157.144]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aOX7E-0003dk-JP for pgsql-hackers@postgresql.org; Wed, 27 Jan 2016 20:55:05 +0000 Received: from [192.168.0.35] (aur75-1-78-192-238-147.fbxo.proxad.net [78.192.238.147]) by mimolette.dalibo.net (Postfix) with ESMTPSA id 9C5FF1F11E65; Wed, 27 Jan 2016 21:54:58 +0100 (CET) Subject: Re: GIN pending list clean up exposure to SQL To: Fujii Masao , Jeff Janes References: <56924D75.7060801@dalibo.com> <569975CD.3070103@dalibo.com> Cc: Jaime Casanova , pgsql-hackers From: Julien Rouhaud X-Enigmail-Draft-Status: N1110 Message-ID: <56A92EA2.9000906@dalibo.com> Date: Wed, 27 Jan 2016 21:54:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 27/01/2016 10:27, Fujii Masao wrote: > On Mon, Jan 25, 2016 at 3:54 PM, Jeff Janes > wrote: >> On Wed, Jan 20, 2016 at 6:17 AM, Fujii Masao >> wrote: >>> On Sat, Jan 16, 2016 at 7:42 AM, Julien Rouhaud >>> wrote: >>>> On 15/01/2016 22:59, Jeff Janes wrote: >>>>> On Sun, Jan 10, 2016 at 4:24 AM, Julien Rouhaud >>>>> wrote: >>>> >>>> All looks fine to me, I flag it as ready for committer. >>> >>> When I compiled the PostgreSQL with the patch, I got the >>> following error. ISTM that the inclusion of pg_am.h header file >>> is missing in ginfast.c. >> >> Thanks. Fixed. >> >>> gin_clean_pending_list() must check whether the server is in >>> recovery or not. If it's in recovery, the function must exit >>> with an error. That is, IMO, something like the following check >>> must be added. >>> >>> if (RecoveryInProgress()) ereport(ERROR, >>> >>> (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), >>> errmsg("recovery is in progress"), errhint("GIN pending list >>> cannot be cleaned up during recovery."))); >>> >>> It's better to make gin_clean_pending_list() check whether the >>> target index is temporary index of other sessions or not, like >>> pgstatginindex() does. >> >> I've added both of these checks. Sorry I overlooked your early >> email in this thread about those. >> >>> >>> + Relation indexRel = index_open(indexoid, >>> AccessShareLock); >>> >>> ISTM that AccessShareLock is not safe when updating the pending >>> list and GIN index main structure. Probaby we should use >>> RowExclusiveLock? >> >> Other callers of the ginInsertCleanup function also do so while >> holding only the AccessShareLock on the index. It turns out >> that there is a bug around this, as discussed in "Potential GIN >> vacuum bug" >> (http://www.postgresql.org/message-id/flat/CAMkU=1xALfLhUUohFP5v33RzedLVb5aknNUjcEuM9KNBKrB6-Q@mail.gmail.com) >> >> >> But, that bug has to be solved at a deeper level than this patch. >> >> I've also cleaned up some other conflicts, and chose a more >> suitable OID for the new catalog function. >> >> The number of new header includes needed to implement this makes >> me wonder if I put this code in the correct file, but I don't see >> a better location for it. >> >> New version attached. > > Thanks for updating the patch! It looks good to me. > > Based on your patch, I just improved the doc. For example, I added > the following note into the doc. > > + These functions cannot be executed during recovery. + Use > of these functions is restricted to superusers and the owner + > of the given index. > > If there is no problem, I'm thinking to commit this version. > Just a detail: + Note that the cleanup does not happen and the return value is 0 + if the argument is the GIN index built with fastupdate + option disabled because it doesn't have a pending list. It should be "if the argument is *a* GIN index" I find this sentence a little confusing, maybe rephrase like this would be better: - Note that the cleanup does not happen and the return value is 0 - if the argument is the GIN index built with fastupdate - option disabled because it doesn't have a pending list. + Note that if the argument is a GIN index built with fastupdate + option disabled, the cleanup does not happen and the return value is 0 + because the index doesn't have a pending list. Otherwise, I don't see any problem on this version. Regards. > Regards, > > > > -- Julien Rouhaud http://dalibo.com - http://dalibo.org -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers