Skip to content

Lower log level for known job conflicts ("Job is already running") #29

@KunBojiMan

Description

@KunBojiMan

When scheduled jobs like scheduleFullSubscriberSyncJob() detect that a job is already running or pending, they throw a controlled exception:

/src/Model/UseCase/ScheduleBackgroundJob.php

Image
if (JobEntity::TYPE_PENDING === $job->getStatus()) {
    throw new JobAlreadyScheduledException('Job is already scheduled.');
} else {
    throw new JobAlreadyRunningException('Job is already running.');
}

These are expected cases but are currently logged as errors in all task handlers:

catch (\Throwable $e) {
    $this->logger->error($e->getMessage());
}

Suggestion:
Log these specific exceptions as info instead:

catch (\Throwable $e) {
    if (
        $e instanceof JobAlreadyRunningException ||
        $e instanceof JobAlreadyScheduledException
    ) {
        $this->logger->info($e->getMessage());
    } else {
        $this->logger->error($e->getMessage());
    }
}

This would reduce noise in logs without changing behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions