-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Unstopped samples in TimedScheduler #3844
Comments
Hi @rethab ! Thanks for describing the issue with a potential reproducer. I was able to reproduce the issue in a more direct way that takes away the cancellation performed on behalf of the
This is indeed a bug. I can't figure out yet if we have means to intercept such scenarios to properly clean the pending timer. I'll try to look into it more. |
The `TimedRunnable` that is created using a `TimedWorker` was not disposed upon `Worker` shutdown. That led the pending tasks timers to run forever, causing leaks. This change keeps track of created `TimedRunnable` instances by the `TimedWorker`, allowing to dispose the resources responsibly. Resolves #3844
@rethab as a matter of fact, the above example has no means to actually work. However, when the |
Hi @chemicL , thanks a lot for the fix!! ❤️ Unfortunately, we only saw the behavior in production after a few hours and I can't use snapshots in production, but I'll surely take it for a spin once the real version is out :) Thanks again! |
Hi @chemicL, I have since had the chance to run this in production and the results look very good. We've been running with a monkey-patched version of the TimedScheduler for a while. Previously, I have removed the pending tasks metric and CPU was stable. A little more than 24 hours ago, we have deployed your fix including the pending tasks metric to production and CPU has been stable since. So I'm pretty confident your fix did the trick. Thanks again for fixing this so quickly 💪 |
Thanks for the feedback, it's awesome to hear the good news @rethab ❤️ |
Decorating the reactor schedulers with TimedScheduler leads to very high CPU in some of our production services.
I'm not entirely sure what the problem is, but I noticed that sometimes, samples in the TimedScheduler are not cleaned up.
Expected Behavior
When a sample is started for the metrics, I expect it to be stopped again.
Actual Behavior
Sometimes, this does not seem to happen.
In particular, I'm looking at the TimedScheduler's
pendingTasks
timer.When a
TimedRunnable
is instantiated, it starts the sample:this.pendingSample = parent.pendingTasks.start();
In both the
run
method and thedispose
method, it stops it again.Internally, when calling
stop
on SampleImpl it removes the sample from the list of active tasks.I noticed in my test run, the pending tasks is sometimes not empty after having run a bunch of Monos.
In other words, this fails:
Additionally, I have also used my own implementation of TimedScheduler and overridden the
finalize
method ofTimedRunnable
. In there, I printed something if thependingSample
was not stopped, but the runnable was garbage collected:(I'm not sure if this is a reliable way to detect this though)
Steps to Reproduce
Possible Solution
???
Your Environment
The text was updated successfully, but these errors were encountered: