Skip to content
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

Signer loop: exit when shutdown signal received during upgrade loop #934

Closed
wants to merge 1 commit into from

Conversation

ok300
Copy link
Contributor

@ok300 ok300 commented Apr 16, 2024

This PR makes the signer upgrade loop exit in case the shutdown signal is received.

The signer loop wrapper method (Greenlight::run_forever) has 2 parts, the upgrade loop (a) and the actual signer loop (b).

Inside it, the upgrade loop (a) has the following logic:

  • try to upgrade the signer with scheduler.maybe_upgrade
    • if maybe_upgrade fails due to a connection issue (error code Code::Unavailable when connecting to the scheduler), wait 3 seconds and retry
    • if maybe_upgrade fails due to any other reason, exit with an error
    • if it succeeds (e.g. returns Ok), then this loop exits and the signer loop (b) starts

The signer loop (b) is already listening and reacting to the shutdown signal.

However, the upgrade loop (a) which is just above it, detailed above, doesn't. This means that, in a situation where the scheduler is not reachable, the upgrade loop (a) would run forever, even if the shutdown signal is received.

This PR wraps scheduler.maybe_upgrade in a tokio::select that also listens to the shutdown signal. If received, the entire signer loop is exited.

@ok300 ok300 force-pushed the ok300-signer-loop-shutdown-signal-handling branch from d7eed26 to 2fea98d Compare April 16, 2024 16:48
@ok300 ok300 requested review from dangeross and roeierez April 16, 2024 16:50
@ok300 ok300 marked this pull request as draft April 16, 2024 20:10
@ok300
Copy link
Contributor Author

ok300 commented Apr 17, 2024

Superseded by #936

@ok300 ok300 closed this Apr 17, 2024
@ok300 ok300 deleted the ok300-signer-loop-shutdown-signal-handling branch June 27, 2024 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant