Replies: 2 comments
-
I think this must be a bug in Is this better? where consecutive_failures > 0 and (last_success is null or last_success < ?)) " I suspect this code might have been written before we started tracking consecutive_failures... |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'm not really sure what the best fix is. It really depends on what exactly you intend the method to do. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've written a Spring Boot Healthcheck to return the status of the tasks I have running. They are recurring tasks with a frequency of 10 minutes.
The idea is for it to fail when there are failures occurring in the tasks.
It's not quite working as expected though. Once a failure occurs the healthcheck fails forever.
This is because theDuration.ofMinutes(1)); call at line 44 is not doing what I would expect.
There is no documentation so I assumed that the duration should be a small one. However I see that in the sql that is used for the method call that is actually used to check whether the last success was greater than that interval in the past, which it almost always will be in my case since the frequency is 10 minutes.
So I could set the interval to greater than 10 minutes, but then that would not do what I want since failures would not be reported by the healthcheck until after 10 minutes has passed.
Instead I think I need this change to my code:
and also:
By checking that the most recent success is more recent than the most recent failure then I can be sure of the status of my tasks and with keeping the interval as it is at 1 minute (or maybe less) then I can be sure that I report my failure state quickly and accurately.
My question is though, why does the scheduler.getFailingExecutions() use the sql it does. Why does it not compare the last_failure and last_success dates, or maybe even look for consecutive_failures > 0 ?
Or is there a better way to write a healthcheck like I would like?
Beta Was this translation helpful? Give feedback.
All reactions