Skip to content

Investigate jobs getting stuck on pending state #14

Open
@thoven87

Description

@thoven87

In some instance jobs can get stuck in pending state while they are not present in the job queue table. Investigate what's causing these jobs to end up in this state. So far, I have seen this happening with schedule jobs where some of the "partitions" are skipped. e.g:

enum StationKind: Codable {
    case bbc
    case bloomberg
}

protocol NewsIngestionJobParameters: Codable, Sendable {
    var kind: StationKind { get set }
}

struct BBCNewsIngestionJobParameters: JobParameters, NewsIngestionJobParameters {
    static let jobName: String = "BBCNewsIngestionJob"
    var kind: StationKind = .bbc
}

struct BloombergNewsIngestionJobParameters: JobParameters, NewsIngestionJobParameters {
    static let jobName: String = "BloombergNewsIngestionJob"
    var kind: StationKind = .bloomberg
}

var jobScheduler = JobSchedule()

jobScheduler.addJob(BirthdayRemindersJobParameters(), schedule: .daily(hour: 9, timeZone: .init(abbreviation: "EST")!))
jobScheduler.addJob(ActivityRemindersJobParameters(), schedule: .daily(hour: 9, timeZone: .init(abbreviation: "EST")!))
jobScheduler.addJob(BBCNewsIngestionJobParameters(), schedule: .onMinutes([0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]))
jobScheduler.addJob(BloombergNewsIngestionJobParameters(), schedule: .onMinutes([0, 10, 20, 30, 40, 50]))

The Bloomberg job gets skipped on minute 10 for a while and after running the job service between a day to a week, we will get job of type BloombergNewsIngestionJobParameters in the jobs table with state pending while there's no reference of these jobs in the queue table.

This behavior is noticed with a docker container with 512MB 1 CPU where concurrency was set between 3 - 100.

These "Jobs" do nothing other than printing "News From Station"

Metadata

Metadata

Assignees

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