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

Why does maxTimeout have no effect on getStats().average? #81

Open
TimDaub opened this issue Jun 29, 2022 · 4 comments
Open

Why does maxTimeout have no effect on getStats().average? #81

TimDaub opened this issue Jun 29, 2022 · 4 comments

Comments

@TimDaub
Copy link
Contributor

TimDaub commented Jun 29, 2022

  • According to the docs: https://github.com/diamondio/better-queue#queue-statistics, getStats().average is the time in milliseconds a task spends executing in the queue
  • So if maxTimeout is set to Infinity then, we'd expect getStats().average to be anywhere between 0 and Infinity
  • However, shouldn't we expect getStats().average to be maximally 5000 if maxTimeout: 5000?

Locally, I've set maxTimeout: 5000 but my average is still climbing. I'm receiving task_timeout in task_failed listener, but I'm wondering why average is higher.
Another contributor opened an issue saying that maxTimeout may not work #75. Is there something to it?

@TimDaub TimDaub changed the title Why does maxTimeout have no effect on getStats().average Why does maxTimeout have no effect on getStats().average? Jun 29, 2022
@TimDaub
Copy link
Contributor Author

TimDaub commented Jun 29, 2022

I looked into how maxTimeout is implemented and I think it isn't what I had expected.

  • What's fine is that a sampling of maxTimeout calls failedBatch peridodically:
    timeout = setTimeout(function () {
  • But in failed batch, it seems it just clears out anyways failed tasks?
    Worker.prototype.failedBatch = function (msg) {
  • My expectation was that it'd remove all on-going tasks that are older than maxTimeout, but I cannot see how it'd do that. I guess it just clears out all tasks every 5 seconds? I'm confused.

@TimDaub
Copy link
Contributor Author

TimDaub commented Jun 29, 2022

e.g. a task has an eta object and so it'd be pretty cool if that was used to filter out all tasks where eta > maxTimeout and then to compensate from niquist-shannon sampling theorem (https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem) it'd probably be better to call setTimeout every maxTimeout/2 to make sure to catch all false requests frequently.

@leanderlee
Copy link
Member

Do you have code that can reproduce this error?

@TimDaub
Copy link
Contributor Author

TimDaub commented Jun 29, 2022

I'll create it and get back to you...

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

2 participants