Skip to content

JobPro.extendLocks may not be extending locks as expected #109

@gl-jkeys

Description

@gl-jkeys

Hello,

We're trying to understand why, under certain circumstances, it seems like our job locks are not being extended properly. We use the batching functionality of BullMQ Pro.

I was reading the BullMQ Pro code, and I noticed this bit of code:

    async extendLock(token, duration) {
        if (this.batch) {
            const multi = (await this.queue.client).multi();
            for (let i = 0; i < this.batch.length; i++) {
                const job = this.batch[i];
                job.extendLock(token, duration);
            }
            const result = await multi.exec();
            const anyError = false;
            for (let i = 0; i < result.length; i++) {
                const [err, code] = result[i];
                if (err) {
                    this.queue.emit('error', err);
                }
                else if (code !== 1) {
                    this.queue.emit('error', new Error(`Error extending lock for job: ${this.batch[i].id}`));
                }
            }
            return anyError ? 0 : 1;
        }
        else {
            return super.extendLock(token, duration);
        }
    }

Specifically, this snippet:

            const multi = (await this.queue.client).multi();
            for (let i = 0; i < this.batch.length; i++) {
                const job = this.batch[i];
                job.extendLock(token, duration);
            }
            const result = await multi.exec();

It looks like a MULTI command gets queued up here, and then executed, but nothing is ever done to the command. Is this intentional?

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