Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zcwe1-00067K-4f for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Sep 2015 14:28:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zcwe0-0002Qa-Mp for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Sep 2015 14:28:08 +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 1Zcwcf-0007zv-UF for pgsql-hackers@postgreSQL.org; Fri, 18 Sep 2015 14:26:45 +0000 Received: from hook.sigaev.ru ([93.180.27.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zcwcb-00044J-IG for pgsql-hackers@postgreSQL.org; Fri, 18 Sep 2015 14:26:45 +0000 Received: from xor.sai.msu.ru (newmail.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: teodor) by hook.sigaev.ru (Postfix) with ESMTPSA id BB7A0B19195; Fri, 18 Sep 2015 17:26:40 +0300 (MSK) Message-ID: <55FC1F20.8030608@sigaev.ru> Date: Fri, 18 Sep 2015 17:26:40 +0300 From: Teodor Sigaev User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33.1 MIME-Version: 1.0 To: Tom Lane , Fujii Masao CC: pgsql-hackers@postgreSQL.org Subject: Re: [COMMITTERS] pgsql: Add pages deleted from pending list to FSM References: <11156.1442582869@sss.pgh.pa.us> In-Reply-To: <11156.1442582869@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------020306070009060602010804" 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 This is a multi-part message in MIME format. --------------020306070009060602010804 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Reply to both emails in one Fujii: > So autoanalyze still doesn't call IndexFreeSpaceMapVacuum(). Fixed, see patch > ginvacuumcleanup calls RecordFreeIndexPage() twice for the same block. fixed too Tom: > It seems quite bizarre for auto-analyze to do that. auto-vacuum, sure, > but I do not think this should get plugged into ANALYZE. I agree, but we want to have pending list shorter as possible. -- Teodor Sigaev E-mail: teodor@sigaev.ru WWW: http://www.sigaev.ru/ --------------020306070009060602010804 Content-Type: text/plain; charset=UTF-8; name="gin_fsm_analyze.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gin_fsm_analyze.patch" diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c index 76bebad..7be9362 100644 --- a/src/backend/access/gin/ginfast.c +++ b/src/backend/access/gin/ginfast.c @@ -434,7 +434,7 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) END_CRIT_SECTION(); if (needCleanup) - ginInsertCleanup(ginstate, false, NULL); + ginInsertCleanup(ginstate, false, true, NULL); } /* @@ -505,7 +505,7 @@ ginHeapTupleFastCollect(GinState *ginstate, */ static bool shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, - IndexBulkDeleteResult *stats) + bool fill_fsm, IndexBulkDeleteResult *stats) { Page metapage; GinMetaPageData *metadata; @@ -732,13 +732,19 @@ processPendingPage(BuildAccumulator *accum, KeyArray *ka, * action of removing a page from the pending list really needs exclusive * lock. * - * vac_delay indicates that ginInsertCleanup is called from vacuum process, - * so call vacuum_delay_point() periodically. + * vac_delay indicates that ginInsertCleanup should so call + * vacuum_delay_point() periodically. + * + * fill_fsm indicates that ginInsertCleanup should add deleted pages + * to FSM otherwise caller is responsible to put deleted pages into + * FSM. + * * If stats isn't null, we count deleted pending pages into the counts. */ void ginInsertCleanup(GinState *ginstate, - bool vac_delay, IndexBulkDeleteResult *stats) + bool vac_delay, bool fill_fsm, + IndexBulkDeleteResult *stats) { Relation index = ginstate->index; Buffer metabuffer, @@ -899,7 +905,7 @@ ginInsertCleanup(GinState *ginstate, * remove read pages from pending list, at this point all * content of read pages is in regular structure */ - if (shiftList(index, metabuffer, blkno, stats)) + if (shiftList(index, metabuffer, blkno, fill_fsm, stats)) { /* another cleanup process is running concurrently */ LockBuffer(metabuffer, GIN_UNLOCK); @@ -948,7 +954,7 @@ ginInsertCleanup(GinState *ginstate, * desirable to recycle them immediately to the FreeSpace Map when * ordinary backends clean the list. */ - if (fsm_vac && !vac_delay) + if (fsm_vac && fill_fsm) IndexFreeSpaceMapVacuum(index); diff --git a/src/backend/access/gin/ginvacuum.c b/src/backend/access/gin/ginvacuum.c index 1315762..323cfb0 100644 --- a/src/backend/access/gin/ginvacuum.c +++ b/src/backend/access/gin/ginvacuum.c @@ -544,7 +544,7 @@ ginbulkdelete(PG_FUNCTION_ARGS) /* Yes, so initialize stats to zeroes */ stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult)); /* and cleanup any pending inserts */ - ginInsertCleanup(&gvs.ginstate, true, stats); + ginInsertCleanup(&gvs.ginstate, true, false, stats); } /* we'll re-count the tuples each time */ @@ -659,7 +659,7 @@ ginvacuumcleanup(PG_FUNCTION_ARGS) if (IsAutoVacuumWorkerProcess()) { initGinState(&ginstate, index); - ginInsertCleanup(&ginstate, true, stats); + ginInsertCleanup(&ginstate, true, true, stats); } PG_RETURN_POINTER(stats); } @@ -672,7 +672,7 @@ ginvacuumcleanup(PG_FUNCTION_ARGS) { stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult)); initGinState(&ginstate, index); - ginInsertCleanup(&ginstate, true, stats); + ginInsertCleanup(&ginstate, true, false, stats); } memset(&idxStat, 0, sizeof(idxStat)); diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h index acbe36a..5021887 100644 --- a/src/include/access/gin_private.h +++ b/src/include/access/gin_private.h @@ -936,7 +936,7 @@ extern void ginHeapTupleFastCollect(GinState *ginstate, OffsetNumber attnum, Datum value, bool isNull, ItemPointer ht_ctid); extern void ginInsertCleanup(GinState *ginstate, - bool vac_delay, IndexBulkDeleteResult *stats); + bool vac_delay, bool fill_fsm, IndexBulkDeleteResult *stats); /* ginpostinglist.c */ --------------020306070009060602010804 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --------------020306070009060602010804--