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

Consider shutdown signal during entire signer loop #936

Merged
merged 4 commits into from
Apr 17, 2024

Conversation

ok300
Copy link
Contributor

@ok300 ok300 commented Apr 16, 2024

Before this PR, the signer loop consisted of

  • signer upgrade loop
    • which disregards the shutdown signal
  • signer loop
    • which reacts to shutdown signal, but only when signer.run_once is not running, which may take 10 minutes to return. In other words, in the worst case the shutdown signal is handled (e.g. signer loop exits) 10 minutes after it's sent.

This PR wraps both loops above in a single run_forever_inner thread. In parallel to it, it listens to the shutdown signal and exits the thread as soon as the signal is received.

Possibly overrides #934.


Note to reviewers / Open question

I'm not sure if the signer upgrade loop (scheduler.maybe_upgrade) should be interrupted in the case of an upgrade. WIth this PR, it would be interrupted if we get a shutdown signal.

On the other hand, as described in #934, if we disregard the shutdown signal while we're in the signer upgrade loop, we may end up in an endless loop in the case when the GL scheduler is not reachable.

What do you think? How to best handle the upgrade loop?

@ok300 ok300 requested review from dangeross, roeierez and JssDWt April 16, 2024 20:05
Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and I tested it successfully!
We should follow up with a PR to Greenlight.

Copy link
Collaborator

@dangeross dangeross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Solves the shutdown issue after interacting with the signer

@ok300
Copy link
Contributor Author

ok300 commented Apr 17, 2024

As discussed, I separated the scheduler loop from the signer loop, such that calls to scheduler.maybe_upgrade remain unaffected by the shutdown signal.

PR is ready for final review.

@ok300 ok300 requested review from dangeross and roeierez April 17, 2024 06:14
@ok300 ok300 marked this pull request as ready for review April 17, 2024 06:14
Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@dangeross dangeross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ok300 ok300 merged commit 370cb6b into main Apr 17, 2024
6 of 7 checks passed
ok300 added a commit that referenced this pull request Apr 17, 2024
* Consider shutdown signal during entire signer loop

* Cargo fmt

* Add comments to run_forever_inner()

* Separate scheduler and signer loop
roeierez added a commit that referenced this pull request May 7, 2024
* commit 'b08215dc4fa98cadb50616a3702bc8f83afaf636':
  Fix indentation on CHANGELOG.md
  Update sdk-flutter plugin changelogs
  Update version to 0.4.0
  Change the redeem swap failure notification to prompt to open the app
  Update version to 0.4.0-rc5
  Move notification source files and change podspecs/package
  Consider shutdown signal during entire signer loop (#936)
  Update version to 0.4.0-rc4 Merge Swift package sources into one BreezSDK target
  Update version to 0.4.0-rc3
  upgrade version to 0.4.0-rc2
  Add a service timeout to the android notification plugin
  Pre-check for a valid notification manager before starting the foreground service
  temporary skip c# tests
  Fix csharp test connect request
  fix test to use production environment
  update versions to 0.4.0
@ok300 ok300 deleted the ok300-signer-loop-shutdown-signal-handling-v3 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.

3 participants