aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/src/sgml/brin.sgml12
-rw-r--r--src/backend/access/brin/brin.c16
-rw-r--r--src/backend/postmaster/autovacuum.c7
-rw-r--r--src/include/postmaster/autovacuum.h2
4 files changed, 32 insertions, 5 deletions
diff --git a/doc/src/sgml/brin.sgml b/doc/src/sgml/brin.sgml
index 23c0e05ed6c..f02e061bc1c 100644
--- a/doc/src/sgml/brin.sgml
+++ b/doc/src/sgml/brin.sgml
@@ -86,6 +86,18 @@
representation because the existing values have changed.
</para>
+ <para>
+ When autosummarization is enabled, each time a page range is filled a
+ request is sent to autovacuum for it to execute a targeted summarization
+ for that range, to be fulfilled at the end of the next worker run on the
+ same database. If the request queue is full, the request is not recorded
+ and a message is sent to the server log:
+<screen>
+LOG: request for BRIN range summarization for index "brin_wi_idx" page 128 was not recorded
+</screen>
+ When this happens, the range will be summarized normally during the next
+ regular vacuum of the table.
+ </para>
</sect2>
</sect1>
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index 68b33716659..0e5849efdcc 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -187,9 +187,19 @@ brininsert(Relation idxRel, Datum *values, bool *nulls,
brinGetTupleForHeapBlock(revmap, lastPageRange, &buf, &off,
NULL, BUFFER_LOCK_SHARE, NULL);
if (!lastPageTuple)
- AutoVacuumRequestWork(AVW_BRINSummarizeRange,
- RelationGetRelid(idxRel),
- lastPageRange);
+ {
+ bool recorded;
+
+ recorded = AutoVacuumRequestWork(AVW_BRINSummarizeRange,
+ RelationGetRelid(idxRel),
+ lastPageRange);
+ if (!recorded)
+ ereport(LOG,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("request for BRIN range summarization for index \"%s\" page %u was not recorded",
+ RelationGetRelationName(idxRel),
+ lastPageRange)));
+ }
else
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
}
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 639bd716b1e..c4bc09ea810 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -3227,12 +3227,14 @@ AutoVacuumingActive(void)
/*
* Request one work item to the next autovacuum run processing our database.
+ * Return false if the request can't be recorded.
*/
-void
+bool
AutoVacuumRequestWork(AutoVacuumWorkItemType type, Oid relationId,
BlockNumber blkno)
{
int i;
+ bool result = false;
LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE);
@@ -3252,12 +3254,15 @@ AutoVacuumRequestWork(AutoVacuumWorkItemType type, Oid relationId,
workitem->avw_database = MyDatabaseId;
workitem->avw_relation = relationId;
workitem->avw_blockNumber = blkno;
+ result = true;
/* done */
break;
}
LWLockRelease(AutovacuumLock);
+
+ return result;
}
/*
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 18cff540b73..96752caed8d 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -71,7 +71,7 @@ extern void AutovacuumWorkerIAm(void);
extern void AutovacuumLauncherIAm(void);
#endif
-extern void AutoVacuumRequestWork(AutoVacuumWorkItemType type,
+extern bool AutoVacuumRequestWork(AutoVacuumWorkItemType type,
Oid relationId, BlockNumber blkno);
/* shared memory stuff */