Skip to content

Removing items in queue using queue.clear function yield strange behaviors #143

@TomShen1234

Description

@TomShen1234

Describe the bug

See below.

To Reproduce

If a job is dispatched to the queue with a delay:

func dispatchJob(on req: Request) -> EventLoopFuture<Void> {
    let newDate = Date().addingTimeInterval(30)
    req.logger.info("Dispatching job at: \(newDate)")
    return req.queue.dispatch(TestJob.self, .init(id: UUID()), delayUntil: newDate, id: JobIdentifier(string: "test-queue-item"))
}

...and you want to cancel it, the only method that appears to do the action is:

req.queue.clear(JobIdentifier(string: "test-queue-item"))

By doing this, what it appears to do is that it removed the actual job information from the Redis database. However, the job is now in the vapor_queues[default]-processing list, but since the actual job information is removed, the console now logs: [ ERROR ] Job run failed: missingJob. From this I assume that this method is only used internally for dequeueing jobs? Especially if I want to reschedule the job with the same JobItentifier, strange behaviors like duplicate dequeues will happen.

If this is the case, can we get a function to remove a dispatched job from the queue? Otherwise, this will be a bug report.

Expected behavior

The item should be removed from the queue properly.

Environment

  • Vapor Framework version: 4.48.5
  • OS version: macOS 12.0 beta

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions