Skip to content

fix(yang-push): defer subscription updates while a schema fetch is in-flight - #35

Open
rodonile wants to merge 1 commit into
network-analytics:mainfrom
rodonile:sub-mod-fix
Open

fix(yang-push): defer subscription updates while a schema fetch is in-flight#35
rodonile wants to merge 1 commit into
network-analytics:mainfrom
rodonile:sub-mod-fix

Conversation

@rodonile

@rodonile rodonile commented Aug 11, 2026

Copy link
Copy Markdown
Member

This PR depends on #29. Issue spotted by @ustorbeck during review or #23.

Problem

A SubscriptionModified arriving while the prior SubscriptionStarted's fetch
was still in-flight caused check_subscription_new to remove the old entry
(silently dropping any buffered packets) and start a second, independent fetch.
The stale first response then clobbered the newer entry and cleared
schema_fetch_pending prematurely — packets could validate against the
wrong schema or slip through unvalidated.

Fix

Defer SubscriptionStarted/SubscriptionModified notifications like
ordinary push-updates whenever a fetch is already pending for that
subscription id, guaranteeing at most one fetch in-flight per id. The
deferred update replays after the buffer drains, correctly triggering a
fresh fetch. Adds a subscription_update_deferred counter.

@rodonile rodonile changed the title Sub mod fix fix(yang-push): defer subscription updates while a schema fetch is in-flight - #4 Aug 11, 2026
@rodonile rodonile changed the title fix(yang-push): defer subscription updates while a schema fetch is in-flight - #4 fix(yang-push): defer subscription updates while a schema fetch is in-flight Aug 11, 2026
@rodonile
rodonile force-pushed the sub-mod-fix branch 2 times, most recently from af0eeae to 94b7e8d Compare August 11, 2026 10:14
@rodonile
rodonile force-pushed the sub-mod-fix branch 2 times, most recently from 4919ed3 to 9f24128 Compare August 13, 2026 09:57
@rodonile rodonile self-assigned this Aug 13, 2026
process_cache_response correlates responses by subscription id only.
A SubscriptionModified arriving while the prior SubscriptionStarted's
fetch was still in-flight caused check_subscription_new to remove the
old entry (dropping buffered packets) and start a second fetch;
the stale first response then clobbered the newer entry and cleared
schema_fetch_pending prematurely.

Defer SubscriptionStarted/SubscriptionModified like ordinary
push-updates whenever a fetch is already pending, so at most one
fetch is ever in-flight per subscription id. Adds
subscription_update_deferred counter and a regression test.
@rodonile
rodonile marked this pull request as ready for review August 18, 2026 15:31
@rodonile
rodonile enabled auto-merge (rebase) August 18, 2026 15:32
@rodonile
rodonile requested review from riccardo-negri and ustorbeck and a lite review from Copilot August 18, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a correctness bug in the YANG-Push validation actor where SubscriptionModified (or duplicate SubscriptionStarted) arriving while a prior schema fetch is still in-flight could clobber cache state, drop buffered packets, and potentially validate packets against the wrong schema. The fix enforces “at most one schema fetch in-flight per (peer, subscription id)” by buffering started/modified notifications while a fetch is pending, and replaying them once the pending fetch resolves.

Changes:

  • Defer (buffer) SubscriptionStarted / SubscriptionModified notifications when schema_fetch_pending is already true for the same subscription id, preventing stale cache responses from overwriting newer subscription generations.
  • Add a new OpenTelemetry counter netcalyx.yang_push.validation.subscription_update.deferred to measure deferred subscription updates.
  • Add a regression test intended to validate correct ordering/behavior when a SubscriptionModified arrives during an in-flight fetch.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +2878 to +2882
// Enqueue all four messages before the actor has any chance to run, so
// fetch #1 (triggered by message 1) is guaranteed to still be pending
// when messages 2-4 are handled.
udp_notif_tx
.send(make_packet(1, &started_payload))
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