Skip to content

State transition can take far too long if system clock is set to an earlier time #1043

@jleveque

Description

@jleveque

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.

I have resolved the issue with the following modification to the transition() function in process.py:

def transition(self):
    now = time.time()
    state = self.state

    logger = self.config.options.logger

    # If system clock has moved backward, reset self.laststart to current system time
    if now < self.laststart:
        self.laststart = now;

   ...

This solution still ensures that the process has remained running for at least self.config.startsecs while only increasing the maximum wait time to 2 * self.config.startsecs if the system clock is detected to have moved backward.

As I'm not too familiar with this code, I'm not sure if this is the best solution, nor am I sure if any other functions may require a check of this nature as well, so I figured I would leave this suggestion here and let a Supervisor dev who is more familiar with the code base decide on the most appropriate solution.

Please let me know if I can be of further assistance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions