pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Teodor Sigaev <teodor@sigaev.ru>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: pgsql-hackers@postgreSQL.org
Subject: Re: [COMMITTERS] pgsql: Add pages deleted from pending list to FSM
Date: Fri, 18 Sep 2015 17:26:40 +0300
Message-ID: <55FC1F20.8030608@sigaev.ru> (raw )
In-Reply-To: <11156.1442582869@sss.pgh.pa.us >
References: <E1ZYwU3-00054w-Gb@gemulon.postgresql.org >
<CAHGQGwEq+1YOazGiDRDs4Eu4wji7X697mUmmh5Yy2UfoacnL8g@mail.gmail.com >
<11156.1442582869@sss.pgh.pa.us >
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
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/
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Attachments:
gin_fsm_analyze.patch (text/plain, 3.8K) download
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 */
view thread (7+ messages) latest in thread
Message-ID: <55FC1F20.8030608@sigaev.ru>
Permalink: ../55FC1F20.8030608@sigaev.ru/
Also on: postgresql.org/message-id/55FC1F20.8030608@sigaev.ru
copy link · copy postgr.es · copy git am
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: teodor@sigaev.ru, tgl@sss.pgh.pa.us, masao.fujii@gmail.com, pgsql-hackers@postgreSQL.org
Subject: Re: [COMMITTERS] pgsql: Add pages deleted from pending list to FSM
In-Reply-To: <55FC1F20.8030608@sigaev.ru>
References: <E1ZYwU3-00054w-Gb@gemulon.postgresql.org> <CAHGQGwEq+1YOazGiDRDs4Eu4wji7X697mUmmh5Yy2UfoacnL8g@mail.gmail.com> <11156.1442582869@sss.pgh.pa.us> <55FC1F20.8030608@sigaev.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox