Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aMhuF-0006s1-GO for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Jan 2016 20:02:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aMhuE-00039i-CG for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Jan 2016 20:02:02 +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 1aMhuD-00039M-GZ for pgsql-hackers@postgresql.org; Fri, 22 Jan 2016 20:02:01 +0000 Received: from mimolette.dalibo.net ([212.85.157.144]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aMhu5-0004pe-4R for pgsql-hackers@postgresql.org; Fri, 22 Jan 2016 20:02:00 +0000 Received: from [192.168.0.204] (bur91-1-82-230-68-10.fbx.proxad.net [82.230.68.10]) by mimolette.dalibo.net (Postfix) with ESMTPSA id EC7B11F11C22; Fri, 22 Jan 2016 21:01:47 +0100 (CET) Subject: Re: GIN pending list clean up exposure to SQL To: Fujii Masao References: <56924D75.7060801@dalibo.com> <569975CD.3070103@dalibo.com> Cc: Jeff Janes , Jaime Casanova , pgsql-hackers From: Julien Rouhaud X-Enigmail-Draft-Status: N1010 Message-ID: <56A28AAA.6050502@dalibo.com> Date: Fri, 22 Jan 2016 21:01:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 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 20/01/2016 15:17, Fujii Masao wrote: > > 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. > > ginfast.c: In function 'gin_clean_pending_list': > ginfast.c:980: error: 'GIN_AM_OID' undeclared (first use in this function) > ginfast.c:980: error: (Each undeclared identifier is reported only once > ginfast.c:980: error: for each function it appears in.) > > 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. > > + 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? > This lock should be safe, as pointed by Alvaro and Jaime earlier in this thread (http://www.postgresql.org/message-id/20151119161846.GK614468@alvherre.pgsql), as ginInsertCleanup() can be called concurrently. Also, since 38710a374ea the ginInsertCleanup() call must be fixed: - ginInsertCleanup(&ginstate, false, true, &stats); + ginInsertCleanup(&ginstate, true, &stats); 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