Repository navigation
sub ntf: fix subscription termination stall and state lookup - #1831
Merged
Merged
Conversation
Destroying a session terminated its subscriptions under the state write lock. srsn_terminate() waits for a push-update in progress, whose sr_get_data() on the operational datastore calls the provider of the subscriptions state, which needs the state lock. Everything stalled until the operational callback timeout, including the sysrepo listener thread. The subscriptions are now only removed from the state under the lock and terminated after unlocking. Their callback arguments are kept until then because the srsn dispatch still uses them. The test needs sysrepo with "sn BUGFIX terminate without the subscription lock", which stopped srsn_terminate() from holding the srsn lock the provider needs as well.
The provider of the subscriptions state looked up the srsn subscriptions with a forward-only scan, assuming they are in the order of the netopeer2 state. srsn moves its last subscription into a removed one's slot, so after removing any but the last one every get of the subscriptions state failed with an internal error. When a subscription was not found, the scan also read past the end of the srsn array. A subscription is also missing in srsn between its termination there and the dispatch of its subscription-terminated notification, which removes it from the state. It is skipped now, the state is added to only after srsn, both under the state lock.
michalvasko
approved these changes
Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/subscriptionsfailing with an internal error after a subscription was removed.Requires sysrepo 5.2.28.