diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 5c04a27eb66..1e2fadffaf1 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -7704,8 +7704,8 @@ log_line_prefix = '%m [%p] %q%u@%d/%a ' - Controls whether a log message is produced to display information on the number of - workers spawned when a parallel query or utility is executed. The default value is + Controls whether a log message about the number of workers produced during an + execution of the parallel query or utility statement. The default value is none which disables logging. all displays information for all parallel queries, whereas failures displays information only when the number of workers launched is lower than the number of diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c index fdfbbc7dc42..3ed10c7f8a0 100644 --- a/src/backend/access/brin/brin.c +++ b/src/backend/access/brin/brin.c @@ -2544,10 +2544,9 @@ _brin_end_parallel(BrinLeader *brinleader, BrinBuildState *state) /* Shutdown worker processes */ WaitForParallelWorkersToFinish(brinleader->pcxt); - if ((log_parallel_workers == LOG_PARALLEL_WORKERS_ALL && - brinleader->pcxt->nworkers_to_launch > 0) || - (log_parallel_workers == LOG_PARALLEL_WORKERS_FAILURE && - brinleader->pcxt->nworkers_to_launch > brinleader->pcxt->nworkers_launched)) + if (LoggingParallelWorkers(log_parallel_workers, + brinleader->pvs->pcxt->parallel_workers_to_launch, + brinleader->pvs->pcxt->parallel_workers_launched)) elog(LOG, "%i workers planned (%i workers launched)", brinleader->pcxt->nworkers_to_launch, brinleader->pcxt->nworkers_launched); diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index e31bd8e223e..85fede89d9f 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -1615,10 +1615,9 @@ _bt_end_parallel(BTLeader *btleader) /* Shutdown worker processes */ WaitForParallelWorkersToFinish(btleader->pcxt); - if ((log_parallel_workers == LOG_PARALLEL_WORKERS_ALL && - btleader->pcxt->nworkers_to_launch > 0) || - (log_parallel_workers == LOG_PARALLEL_WORKERS_FAILURE && - btleader->pcxt->nworkers_to_launch > btleader->pcxt->nworkers_launched)) + if (LoggingParallelWorkers(log_parallel_workers, + btleader->pvs->pcxt->parallel_workers_to_launch, + btleader->pvs->pcxt->parallel_workers_launched)) elog(LOG, "%i workers planned (%i workers launched)", btleader->pcxt->nworkers_to_launch, btleader->pcxt->nworkers_launched); diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c index d4e84aabac7..d3e37915fdf 100644 --- a/src/backend/access/transam/parallel.c +++ b/src/backend/access/transam/parallel.c @@ -1627,3 +1627,17 @@ LookupParallelWorkerFunction(const char *libraryname, const char *funcname) return (parallel_worker_main_type) load_external_function(libraryname, funcname, true, NULL); } + +/* + * The function determines of logging information + * about workers. +*/ +LoggingParallelWorkers(int log_parallel_workers, + int parallel_workers_to_launch, + int parallel_workers_launched) +{ + return ((log_parallel_workers == LOG_PARALLEL_WORKERS_ALL && + parallel_workers_to_launch > 0) || + (log_parallel_workers == LOG_PARALLEL_WORKERS_FAILURE && + parallel_workers_to_launch != parallel_workers_launched)); +} \ No newline at end of file diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c index e207a6b7d91..bae64b07e9a 100644 --- a/src/backend/commands/vacuumparallel.c +++ b/src/backend/commands/vacuumparallel.c @@ -208,9 +208,6 @@ struct ParallelVacuumState int nindexes_parallel_cleanup; int nindexes_parallel_condcleanup; - int nworkers_to_launch; - int nworkers_launched; - /* Buffer access strategy used by leader process */ BufferAccessStrategy bstrategy; @@ -365,8 +362,8 @@ parallel_vacuum_init(Relation rel, Relation *indrels, int nindexes, if ((vacoptions & VACUUM_OPTION_PARALLEL_COND_CLEANUP) != 0) pvs->nindexes_parallel_condcleanup++; } - pvs->nworkers_to_launch = 0; - pvs->nworkers_launched = 0; + pcxt->nworkers_to_launch = 0; + pcxt->nworkers_launched = 0; shm_toc_insert(pcxt->toc, PARALLEL_VACUUM_KEY_INDEX_STATS, indstats); pvs->indstats = indstats; @@ -443,13 +440,12 @@ parallel_vacuum_end(ParallelVacuumState *pvs, IndexBulkDeleteResult **istats) { Assert(!IsParallelWorker()); - if ((log_parallel_workers == LOG_PARALLEL_WORKERS_ALL && - pvs->nworkers_to_launch > 0) || - (log_parallel_workers == LOG_PARALLEL_WORKERS_FAILURE && - pvs->nworkers_to_launch > pvs->nworkers_launched)) + if (LoggingParallelWorkers(log_parallel_workers, + pvs->pcxt->parallel_workers_to_launch, + pvs->pcxt->parallel_workers_launched)) elog(LOG, "%i workers planned to be launched for index cleanup and bulkdelete (%i workers launched)", - pvs->nworkers_to_launch, - pvs->nworkers_launched); + pvs->pcxt->nworkers_to_launch, + pvs->pcxt->nworkers_launched); /* Copy the updated statistics */ for (int i = 0; i < pvs->nindexes; i++) @@ -754,8 +750,8 @@ 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]); - pvs->nworkers_to_launch += pvs->pcxt->nworkers_to_launch; - pvs->nworkers_launched += pvs->pcxt->nworkers_launched; + pvs->pcxt->nworkers_to_launch += pvs->pcxt->nworkers_to_launch; + pvs->pcxt->nworkers_launched += pvs->pcxt->nworkers_launched; } /* diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 6663fea7b12..b85d679b7fd 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -483,10 +483,9 @@ standard_ExecutorEnd(QueryDesc *queryDesc) Assert(estate != NULL); - if ((log_parallel_workers == LOG_PARALLEL_WORKERS_ALL && - estate->es_parallel_workers_to_launch > 0) || - (log_parallel_workers == LOG_PARALLEL_WORKERS_FAILURE && - estate->es_parallel_workers_to_launch != estate->es_parallel_workers_launched)) + if (LoggingParallelWorkers(log_parallel_workers, + estate->es_parallel_workers_to_launch, + estate->es_parallel_workers_launched)) elog(LOG, "%i parallel nodes planned (%i obtained all their workers, %i obtained none), " "%i workers planned to be launched (%i workers launched)", estate->es_parallel_nodes, diff --git a/src/include/access/parallel.h b/src/include/access/parallel.h index ed33e545d76..00aad1e742a 100644 --- a/src/include/access/parallel.h +++ b/src/include/access/parallel.h @@ -93,4 +93,8 @@ extern void ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end); extern void ParallelWorkerMain(Datum main_arg); +extern bool LoggingParallelWorkers(int log_parallel_workers, + int parallel_workers_to_launch, + int parallel_workers_launched); + #endif /* PARALLEL_H */