-
Notifications
You must be signed in to change notification settings - Fork 13
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
Skip refresh if the previous refresh is ongoing #42
Conversation
@jmacxx Could you test this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also thought re-entrancy could have been the problem @alvasw. To investigate (prior to this PR) I made an http server on a separate machine posing as a dummy poloniex provider that would accept the request and block for a while before sending the response. I increased the frequency of refresh() period to 10 seconds while the http call was taking 20 seconds to respond. This was an attempt to reproduce the bug by having multiple refresh() calls ongoing. However this did not happen, in the TimerTask loop a second refresh would not occur until the in-progress one completed. This indicates that TimerTask is a single thread, and documentation agrees. I ran the test for an extended period of time (>24h).
https://stackoverflow.com/questions/1237804/is-javas-timer-task-guaranteed-not-to-run-concurrently
So I think the re-entrancy guard unlikely to fix the issue.
But in absence of other ideas perhaps it is worth deploying it to production anyway. If we do that, there should be a prominent comment next to the re-entrancy guard explaining it, or giving context. Also I think the Refresh in progress. Skipping this iteration
message should be warn level, not debug.
The JDK |
However I don't think that this PR will fix the bug in #33 . |
Looking at it from another angle, pricenode provider has an entry point from SpringBoot start(). What if SpringBoot invokes this more than once, from different threads? That could cause a problem as there's currently no guard against that.
If you would adapt this PR to guard against re-entrancy from SpringBoot, I think it would be better. |
@alvasw Are you still working on this PR? |
I'm closing this PR for now. |
Related to #33