1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-16 17:07:43 +03:00

Make struct ParallelSlot private within pg_dump/parallel.c.

The only field of this struct that other files have any need to touch
is the pointer to the TocEntry a worker is working on.  (Well,
pg_backup_archiver.c is actually looking at workerStatus too, but that
can be finessed by specifying that the TocEntry pointer is NULL for a
non-busy worker.)

Hence, move out the TocEntry pointers to a separate array within
struct ParallelState, and then we can make struct ParallelSlot private.

I noted the possibility of this previously, but hadn't got round to
actually doing it.

Discussion: <1188.1464544443@sss.pgh.pa.us>
This commit is contained in:
Tom Lane
2016-09-27 14:29:12 -04:00
parent fb03d08a89
commit 0109ab2760
3 changed files with 65 additions and 54 deletions

View File

@@ -4027,8 +4027,10 @@ get_next_work_item(ArchiveHandle *AH, TocEntry *ready_list,
for (k = 0; k < pstate->numWorkers; k++)
{
if (pstate->parallelSlot[k].workerStatus == WRKR_WORKING &&
pstate->parallelSlot[k].te->section == SECTION_DATA)
TocEntry *running_te = pstate->te[k];
if (running_te != NULL &&
running_te->section == SECTION_DATA)
count++;
}
if (pstate->numWorkers == 0 || count * 4 < pstate->numWorkers)
@@ -4049,12 +4051,10 @@ get_next_work_item(ArchiveHandle *AH, TocEntry *ready_list,
*/
for (i = 0; i < pstate->numWorkers; i++)
{
TocEntry *running_te;
TocEntry *running_te = pstate->te[i];
if (pstate->parallelSlot[i].workerStatus != WRKR_WORKING)
if (running_te == NULL)
continue;
running_te = pstate->parallelSlot[i].te;
if (has_lock_conflicts(te, running_te) ||
has_lock_conflicts(running_te, te))
{