mojolicious / minion

:octopus: Perl high performance job queue

Home Page:https://metacpan.org/release/Minion

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow setting dequeue wait timeout for Minion::Command::minion::worker

sonntagd opened this issue · comments

  • Minion version: 7.03
  • Perl version: 5.18.2
  • Operating system: Linux

Steps to reproduce the behavior

I am currently using the Minion job queue with a Mojolicious app and with the SQLite backend. I have some jobs that need to be started very soon. We have workers running, but they wait too long.

I am starting the worker like this:

script/myapp minion worker

The sub Minion::Command::minion::worker::_work calls the dequeue method with a hard-coded wait time of 5 seconds: https://metacpan.org/source/SRI/Minion-7.05/lib/Minion/Command/minion/worker.pm#L81

This leads to the situation that a job that was enqueued one second after calling the dequeue method, it waits about four seconds until the job gets started. In most cases this won't be a problem, but in our use case it does.

I suggest to make this 5 a parameter that can be called like this:

script/myapp minion worker -w 0.5

The 5 would stay the default value if no other value is given.
I could try to provide a pull request if you argue for it.

I don't know about this. Have you reported the problem for Minion::Backend::SQLite directly? This is kind of an implementation detail that i'd rather not expose as a command line option. Especially since it's not a problem for Minion::Backend::Pg.

Yea, after looking at the Minion::Backend::SQLite code i think this is a bug there. Those 5 seconds are merely a suggestion for how long the backend can block waiting for new jobs. But the backend is not meant to just sleep for 5 seconds.