Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requesting Guidance on Configuring Lock Duration and Max Stalled Count in Bull Configuration. #2501

Open
Jayshri-Intlon opened this issue Apr 1, 2024 · 2 comments

Comments

@Jayshri-Intlon
Copy link

Jayshri-Intlon commented Apr 1, 2024

Issue:

In my project, I have a job queue named 'entityCreateQueue' that runs periodically to complete certain tasks within a specific timeframe. However, I've noticed that sometimes it generates duplicates shortly after completing a task. To address this issue, I've encountered recommendations to set a 'lockDuration' with a larger value and a 'maxStalledCount' to 0, as mentioned in the references I've consulted. However, I'm uncertain about where and how to configure these settings within my Bull queue in the Nest JS application.

Reference:

Code snippet

import { RedisConfigService } from '../app/config/redis-config.service';
import type { RegisterQueueOptions } from '@nestjs/bullmq';
import { BullModule } from '@nestjs/bullmq';

const redisConfigService = new RedisConfigService(process.env);
const bullOptions: RegisterQueueOptions = {
  name: 'entityCreateQueue',
  connection: redisConfigService.bullConfig.connection,
};

@Module({
  imports: [
    TypeOrmModule.forFeature([Entity, EntityStatusHistory]),
    BullModule.registerQueue(bullOptions),
  ],
@sinasalek
Copy link

There is almost no data regarding this issue with is very strange!

@manast
Copy link
Contributor

manast commented May 17, 2024

Not sure what the issue is here. So, a job that is not keeping the event loop busy will not have any issues, you should not change the lockDuration setting unless you are very aware of why you need to do it. Most likely what you need to do is make sure your job is not keeping the event loop busy for more than a few milliseconds. This is documented in several places, also it is a standard NodeJS good practice: https://blog.searchmyexpert.com/nodejs-event-loop/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants