-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[process.py] Handle scenario where system clock rolls backward #1047
[process.py] Handle scenario where system clock rolls backward #1047
Conversation
Thanks for looking into this issue and for your work on this pull request (with tests!). I definitely think we need to fix this issue. A concern that I have reading this diff is the way these checks are inlined. There is now as much code for checking time rollback as there is actual state transition logic. I think this makes the transition logic more difficult to follow. Can we separate these concerns somehow, e.g. can we do something like check for rollback once at the top of |
39bab51
to
8b0d1a3
Compare
…s class in order to streamline code a bit
8b0d1a3
to
75e9804
Compare
I pushed some changes a few weeks ago in an attempt to address your comments above. Please review the latest changes when you have a moment. |
Update: It appears I missed at least one case where system clock rollback can still cause issues. With this patch, the issue is encountered far less frequently, but it appears it is not complete. @mnaberez: What are your thoughts on using monotonic time throughout supervisor? I think this would prevent the need for checking for system clock rollback and subsequent adjustments. |
I think it's a good idea but it's not available on all versions of Python that Supervisor supports. There was a PR submitted that added monotonic time for old Python versions using |
@mnaberez If you believe it's a must to keep supporting Python versions older than 3 when 3 has been around for 10 years now, then no argument there (I personally would drop the support but my take on this has no bearing in that decision). It's important however to bring stability to supervisord in my opinion hence I would recommend moving ahead with the suggestion you made in #468 (comment). Is this something acceptable and can be done relatively quickly? |
Supervisor is over 14 years old and for most of that time, it ran only on Python 2. Consequently, it still has a large installed base of Python 2 users today. We've made significant efforts to support both 2 and 3 due to our installed base, and we'll continue to support them so they receive bug fixes until they can transition to 3.
This patch (#1047) or something like it should probably done to fix the issue on installations where monotonic time is not available. It should be fine to also add something like #468 (comment). When monotonic time is available, the checks here would just not be triggered. |
@mnaberez: Have you looked into the package I linked above: https://pypi.org/project/monotonic/? I do not have experience with it, but apparently it is an implementation of monotonic time for both Python 2 and 3:
|
I did. I looked at the source and it uses the same |
…rolled back to be less than startsecs
…ck to be less than startsecs
Added a patch (and related test) to prevent a crash when a process has already entered the RUNNING state but then clock rolled back to be less than
|
…tart before ntp-config service (sonic-net#2335)" Supervisor now handles the case where the time jumps back, now that Supervisor/supervisor#1047 has been merged. This reverts commit 298d2ad.
Resolves State transition can take far too long if system clock is set to an earlier time #1043
If the system clock is set to an earlier time after a process is started but before it has entered the RUNNING state, supervisorctl start <process_name> can hang for a very long time waiting for the current system time to become greater than self.laststart + self.config.startsecs, depending on how far backward the system time has moved.
This pull request resolves the issue above and also attempts to address a couple other potential issues in process.py with system time moving backward.
Also added related unit tests