Skip to content

sub ntf: fix subscription termination stall and state lookup - #1831

Merged
michalvasko merged 2 commits into
develfrom
sub-ntf-terminate-unlocked
Oct 19, 2026
Merged

michalvasko merged 2 commits into
develfrom
sub-ntf-terminate-unlocked

Conversation

@Roytak

@Roytak Roytak commented Oct 19, 2026

Copy link
Copy Markdown
Contributor
  • Fixes closing a session stalling until the operational data timeout while a periodic push-update was in progress.
  • Fixes getting /subscriptions failing with an internal error after a subscription was removed.

Requires sysrepo 5.2.28.

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
michalvasko merged commit 9eabbfa into devel Oct 19, 2026
7 checks passed
@michalvasko
michalvasko deleted the sub-ntf-terminate-unlocked branch October 19, 2026 09:36
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.

2 participants