db-scheduler icon indicating copy to clipboard operation
db-scheduler copied to clipboard

Add support for detecting misfires in StatsRegistry

Open vivekkothari opened this issue 3 years ago • 8 comments

Add support for detecting misfires in StatsRegistry. Thanks for building support for micrometer out of the box. It would be really great if you can add support for detecting misfires. We can take a misfireToleranceThreshold as a config param and compare the current time - misfireDuration to executionTime to see if its a misfire. If it is, increment a counter.

vivekkothari avatar Nov 27 '21 04:11 vivekkothari

I can spin up a PR if you think it's useful.

vivekkothari avatar Nov 27 '21 10:11 vivekkothari

Hi! What would be the definition of a misfire?

kagkarlsson avatar Dec 07 '21 21:12 kagkarlsson

If the execution_time of a schedule is say x, and it was picked by db-scheduler at x + 1 min, then its a misfire. We can have a misfireToleranceThreshold which is say 10 seconds, so if the schedule was picked +- 10 seconds of its execution time, then its not a misfire.

vivekkothari avatar Dec 09 '21 12:12 vivekkothari

Ah I understand. Then I think it would be a misfire if (pickedTime - executionTime) - pollingInterval > misfireToleranceThreshold as the Scheduler currently works. It does not currently peek ahead to know when the next execution will be available for running

kagkarlsson avatar Dec 09 '21 13:12 kagkarlsson

PRs are welcome :)

kagkarlsson avatar Dec 09 '21 13:12 kagkarlsson

Oh. Are there plans to look ahead for selecting upcoming schedules?

vivekkothari avatar Dec 09 '21 13:12 vivekkothari

It is something I have thought of, but not implemented. Should be fairly easy. After polling for new executions, run an additional query to see when the next execution is due. If sooner than polling-interval, only sleep for that time

kagkarlsson avatar Dec 09 '21 14:12 kagkarlsson

All scheduler-instances will compete for it though, but no big deal I think.

kagkarlsson avatar Dec 09 '21 14:12 kagkarlsson