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

shutting down a component with messages left in the outbox considered harmful #309

Open
DaanVanVugt opened this issue Feb 7, 2025 · 3 comments

Comments

@DaanVanVugt
Copy link
Collaborator

We just encountered a case where a reuse_instance call was not done at the end of the internal loop. This caused the instance to shut down, while there were still listeners attached, who could then not contact the component anymore.

Does it make sense to hook into a 'clean' shutdown process (can we even do that?) and log a warning if the outbox is not fully emptied? Perhaps a finalize call should do this kind of things?

@LourensVeen
Copy link
Contributor

I considered a finalize call, but people can forget that just as easily, so I didn't think it would actually make things better. That's why I fudged the shutdown procedure into the reuse_instance() call.

Of course then you could forget that, especially if you're using some framework or something that doesn't allow you to write a real reuse loop. I suppose we could have a finalize() function that just does the shutdown and warns if we were supposed to run again for that situation, but it might muddy the waters more rather than clean them up. Plus we would then probably want to have an initialize() instead of the first reuse_instance() for symmetry, and then we have a constructor and also an initialize() function which would be weird.

Ideally, all languages would do RAII and then we could do something like this in the Instance destructor, but alas, Python only automatically manages memory and Fortran does have RAII now, but it's not implemented correctly anywhere so we can't use it.

In the end MUSCLE3 is a cooperative system, and if one of the components misbehaves then the others cannot do much else than log an error and quit, which I think is what they're already doing? Maybe that warning should point to a documentation page that lists possible reasons why the other code crashed, and includes a missing reuse_instance() call?

@DaanVanVugt
Copy link
Collaborator Author

Maybe that warning should point to a documentation page that lists possible reasons why the other code crashed, and includes a missing reuse_instance() call?

I think that would be best indeed, it is unfortunately relatively common for folks to call the API the wrong way

@LourensVeen
Copy link
Contributor

We do have the ApiGuard now at least, that helps. Do you have any ideas on why things go wrong? Is the documentation not clear enough, or do the examples not match the environment people are in so that they become unhelpful or even misleading? Does the API itself fit into people's code poorly?

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

No branches or pull requests

2 participants