Skip to content

JobLock Plugin - beforePerform behaviour #787

@jamagalhaes

Description

@jamagalhaes

Hey,

I found an issue related with JobLock Plugin. By default, JobLock re-enqueues a job if its key was already set. If, for some reason, renqueue fails the error will be caught in here:

} catch (error) {
this.error = error;
if (!triedAfterPerform) {
try {
await RunPlugins(
this,
"afterPerform",
job.class,
this.queue,
this.jobs[job.class],
job.args
);
} catch (error) {
if (error && !this.error) {
this.error = error;
}
}
}
return this.completeJob(!this.error, startedAt);
}

and afterPerform stage will be executed anyway. This will cause JobLock key to be deleted and it will completely break the plugin purpose because it immediately allows other jobs(that share the same key) to be executed concurrently.

Possible solutions:

  1. refactor Joblock beforePerform() stage to handle any possible errors when re-enqueing
  2. don't call RunPlugins('afterPerform') if job perform wasn't effectively called.

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions