0001_masahiko.patch
application/octet-stream
Filename: 0001_masahiko.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/commands/vacuumparallel.c | 7 | 10 |
| src/backend/postmaster/autovacuum.c | 11 | 19 |
diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c
index 6a3a00585f9..cb42d4e572f 100644
--- a/src/backend/commands/vacuumparallel.c
+++ b/src/backend/commands/vacuumparallel.c
@@ -656,7 +656,7 @@ parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scan
nworkers = Min(nworkers, pvs->pcxt->nworkers);
/*
- * Reserve workers in autovacuum global state. Note, that we may be given
+ * Reserve workers in autovacuum global state. Note that we may be given
* fewer workers than we requested.
*/
if (AmAutoVacuumWorkerProcess() && nworkers > 0)
@@ -706,15 +706,12 @@ parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scan
LaunchParallelWorkers(pvs->pcxt);
- if (AmAutoVacuumWorkerProcess() &&
- pvs->pcxt->nworkers_launched < nworkers)
- {
- /*
- * Tell autovacuum that we could not launch all the previously
- * reserved workers.
- */
+ /*
+ * Tell autovacuum that we could not launch all the previously
+ * reserved workers.
+ */
+ if (AmAutoVacuumWorkerProcess() && pvs->pcxt->nworkers_launched < nworkers)
AutoVacuumReleaseParallelWorkers(nworkers - pvs->pcxt->nworkers_launched);
- }
if (pvs->pcxt->nworkers_launched > 0)
{
@@ -765,7 +762,7 @@ parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scan
for (int i = 0; i < pvs->pcxt->nworkers_launched; i++)
InstrAccumParallelQuery(&pvs->buffer_usage[i], &pvs->wal_usage[i]);
- /* Also release all previously reserved parallel autovacuum workers */
+ /* Release all the reserved parallel workers for autovacuum */
if (AmAutoVacuumWorkerProcess() && pvs->pcxt->nworkers_launched > 0)
AutoVacuumReleaseParallelWorkers(pvs->pcxt->nworkers_launched);
}
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index bc11970bfee..6ccc88c4e1e 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -152,8 +152,9 @@ static double av_storage_param_cost_delay = -1;
static int av_storage_param_cost_limit = -1;
/*
- * Variable to keep number of currently reserved parallel autovacuum workers.
- * It is only relevant for parallel autovacuum leader process.
+ * Tracks the number of parallel workers currently reserved by the
+ * autovacuum worker. This is non-zero only for the parallel autovacuum
+ * leader process.
*/
static int av_nworkers_reserved = 0;
@@ -3407,33 +3408,24 @@ AutoVacuumRequestWork(AutoVacuumWorkItemType type, Oid relationId,
}
/*
- * In order to meet the 'autovacuum_max_parallel_workers' limit, leader
- * autovacuum process must call this function during computing the parallel
- * degree.
+ * Reserves parallel workers for autovacuum.
*
- * 'nworkers' is the desired number of parallel workers to reserve. Function
- * sets 'nworkers' to the number of parallel workers that actually can be
- * launched and reserves these workers (if any) in global autovacuum state.
- *
- * NOTE: We will try to provide as many workers as requested, even if caller
- * will occupy all available workers.
+ * nworkers is an in/out parameter; the requested number of parallel workers
+ * to reserve by the caller, and set to the actual number of reserved workers.
*/
void
AutoVacuumReserveParallelWorkers(int *nworkers)
{
- /* Only leader worker can call this function. */
+ /* Only leader autovacuum worker can call this function. */
Assert(AmAutoVacuumWorkerProcess() && !IsParallelWorker());
- /*
- * We can only reserve workers at the beginning of parallel index
- * processing, so we must not have any reserved workers right now.
- */
+ /* The worker must not have any reserved workers yet */
Assert(av_nworkers_reserved == 0);
LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE);
/* Provide as many workers as we can. */
- *nworkers= Min(AutoVacuumShmem->av_freeParallelWorkers, *nworkers);
+ *nworkers = Min(AutoVacuumShmem->av_freeParallelWorkers, *nworkers);
AutoVacuumShmem->av_freeParallelWorkers -= *nworkers;
/* Remember how many workers we have reserved. */
@@ -3632,8 +3624,8 @@ check_av_worker_gucs(void)
}
/*
- * Make sure that number of free parallel workers corresponds to the
- * autovacuum_max_parallel_workers parameter (after it was changed).
+ * Adjusts the number of free parallel workers corresponds to the new
+ * autovacuum_max_parallel_workers value.
*/
static void
adjust_free_parallel_workers(int prev_max_parallel_workers)