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

Safely stop agent heartbeat and handle Disconnected exception #419

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

BrianJKoopman
Copy link
Member

Description

This PR adds a check to make sure the heartbeat is still running before trying to stop the looping call, self.heartbeat_call. We also add exception handling for the autobahn.exception.Disconnected exception we've been seeing occasionally when an agent loses its connection to the crossbar server and goes to flush its feed buffer.

Motivation and Context

If an agent loses its connection to the crossbar server the heartbeat looping call might crash before it is stopped when onLeave() is triggered. This hits an assertion error in twisted.

Additionally, when the agent goes to flush its buffer by publishing any data it has that publish call will fail with an autobahn.exception.Disconnected exception. We were already handling the TransportLost exception, so we just add Disconnected.

An example of hitting both of these at the same time can be see in #417.

Resolves #417.

How Has This Been Tested?

I haven't been able to reproduce #417 locally. I've tried by running a small ocs network with the registry and several fake data agents. I then cycle the crossbar server over and over again, hoping to hit the exception just right. Cycling a couple dozen times never hit it.

I'm still going to try to think of a way to reproduce this, but wanted to get the PR open.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link
Collaborator

@jlashner jlashner left a comment

Choose a reason for hiding this comment

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

Thanks Brian, these changes seem to me like they should help!

@BrianJKoopman BrianJKoopman merged commit 75fe1a2 into main Jan 17, 2025
4 checks passed
@BrianJKoopman BrianJKoopman deleted the koopman/safely-stop-heartbeat branch January 17, 2025 19:56
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.

Registry Agent sometimes does not recover from crossbar disconnect
2 participants