Skip to content

Commit d4a7436

Browse files
author
Antonin Houska
committed
Simplify get_unused_task().
This should have been done in the commit 3ec74c0.
1 parent cf369b8 commit d4a7436

File tree

1 file changed

+4
-34
lines changed

1 file changed

+4
-34
lines changed

worker.c

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,6 @@ squeeze_table_new(PG_FUNCTION_ARGS)
519519
*
520520
* If NULL is returned, *duplicate tells whether it's due to an existing task
521521
* for given relation.
522-
*
523-
* If 'dbid' is invalid, (i.e. caller is requesting a "cleanup only task"), do
524-
* not check for duplicates.
525522
*/
526523
static WorkerTask *
527524
get_unused_task(Oid dbid, char *relschema, char *relname, int *task_idx,
@@ -531,10 +528,6 @@ get_unused_task(Oid dbid, char *relschema, char *relname, int *task_idx,
531528
WorkerTask *task;
532529
WorkerTask *result = NULL;
533530
int res_idx = -1;
534-
bool cleanup_only = !OidIsValid(dbid);
535-
536-
Assert((!cleanup_only && relschema && relname) ||
537-
(cleanup_only && relschema == NULL && relname == NULL));
538531

539532
*duplicate = false;
540533

@@ -572,15 +565,8 @@ get_unused_task(Oid dbid, char *relschema, char *relname, int *task_idx,
572565
/*
573566
* Consider tasks which might be in progress for possible
574567
* duplicates of the task we're going to submit.
575-
*
576-
* No need to check if the task should only do the initial
577-
* cleanup - this task is only created by the scheduler during
578-
* the startup. Even if a duplicate was created somehow, it
579-
* will make the worker exit too early to waste much CPU time
580-
* or to cause ERROR(s).
581568
*/
582-
if (!cleanup_only)
583-
needs_check = true;
569+
needs_check = true;
584570
}
585571
else if (result == NULL)
586572
{
@@ -626,14 +612,6 @@ get_unused_task(Oid dbid, char *relschema, char *relname, int *task_idx,
626612
*/
627613
clear_task(task);
628614
}
629-
630-
/*
631-
* Exit early if there's no need to check for duplicates. (That might
632-
* also imply missed opportunities to reset tasks that became UNUSED
633-
* recently. We'll do that later when looking for regular tasks.)
634-
*/
635-
if (result && cleanup_only)
636-
break;
637615
}
638616
if (result == NULL || *duplicate)
639617
goto done;
@@ -651,16 +629,8 @@ get_unused_task(Oid dbid, char *relschema, char *relname, int *task_idx,
651629
* uniqueness of the task.
652630
*/
653631
result->dbid = dbid;
654-
if (!cleanup_only)
655-
{
656-
namestrcpy(&result->relschema, relschema);
657-
namestrcpy(&result->relname, relname);
658-
}
659-
else
660-
{
661-
NameStr(result->relschema)[0] = '\0';
662-
NameStr(result->relname)[0] = '\0';
663-
}
632+
namestrcpy(&result->relschema, relschema);
633+
namestrcpy(&result->relname, relname);
664634
done:
665635
LWLockRelease(workerData->lock);
666636
*task_idx = res_idx;
@@ -1936,7 +1906,7 @@ process_task_internal(MemoryContext task_cxt)
19361906
{
19371907
/*
19381908
* TopMemoryContext is o.k. here, this worker only processes a single
1939-
* task and then exists.
1909+
* task and then exits.
19401910
*/
19411911
create_replication_slots(1, TopMemoryContext);
19421912
task->repl_slot = squeezeWorkerSlots[0];

0 commit comments

Comments
 (0)