[xcvrd]: Fast-path wait_for_port_config_done() via APPL_DB existence check#857
[xcvrd]: Fast-path wait_for_port_config_done() via APPL_DB existence check#857gs1571 wants to merge 2 commits into
Conversation
…check * wait_for_port_config_done() (in both DaemonXcvrd and CmisManagerTask) subscribes to APPL_DB PORT_TABLE via SubscriberStateTable and blocks until it observes a live pub/sub SET notification with key PortConfigDone or PortInitDone. portsyncd emits this notification exactly once, when swss finishes initial port bring-up. * If xcvrd (re)starts after that one-time notification already fired (e.g. a crash-restart, or any restart of xcvrd alone without a corresponding swss restart/config reload), the subscription starts too late: the notification is gone, but the key itself is still a normal, queryable entry in APPL_DB. The daemon then blocks in this wait loop forever, and never processes any port. * Add a fast-path check via appl_db.exists() for either key before subscribing. If either is already present, return immediately. Signed-off-by: Grigory Solovyev <gs1571@gmail.com>
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
…ast path The fast-path check was duplicated into CmisManagerTask.wait_for_port_config_done but only DaemonXcvrd's copy had a corresponding unit test, leaving the new lines in cmis_manager_task.py uncovered and failing the diff-coverage gate. Signed-off-by: Grigory Solovyev <gs1571@gmail.com>
|
/azp run |
1 similar comment
|
/azp run |
|
Commenter does not have sufficient privileges for PR 857 in repo sonic-net/sonic-platform-daemons |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
|
I am not confident the premise of "the subscription starts too late: the notification itself is gone" -> we now get stuck forever is actually true here. Independent restart of Is it possible that there was a downstream issue here in the likes of the |
Good catch on the constructor snapshot — you're right that SubscriberStateTable's constructor pre-loads existing keys into
The first
So the actual mechanism isn't "the pub/sub event is lost" — it's a cache-visibility gap between ConsumerTableBase's own buffering and Select's per-selectable cache tracking, and it triggers deterministically whenever the snapshot has more than one key before the target key, which is always true in production ( Two ways to fix it:
Happy to add (2) alongside (1), or drop (1) in favor of (2). |
|
I suspect you may be on some older version of the codebase or something?
|
|
You're right, and thanks for pushing on this — I went through the swss-common source and reproduced it on hardware; the premise doesn't hold. Walking the actual code (master):
I also verified on the switch: creating a The hang I attributed to this was a different, downstream issue on our (vendor-forked) build. Closing this PR — thanks again for the careful review. |
Description
wait_for_port_config_done()(present in bothDaemonXcvrdandCmisManagerTask, identical logic in each) subscribes to APPL_DBPORT_TABLEviaSubscriberStateTableand blocks until it observes alive pub/sub SET notification with key
PortConfigDoneorPortInitDone.portsyncdemits this notification exactly once, whenswssfinishes initial port bring-up.If
xcvrd(re)starts after that one-time notification already fired — e.g.a crash-restart, or any restart of
xcvrdalone without a correspondingswssrestart/config reload— the subscription starts too late: thenotification itself is gone, but the underlying key is still a normal,
queryable entry in APPL_DB. The daemon then blocks in this wait loop
forever and never processes any port on the switch.
Added a fast-path check via
appl_db.exists()for either key beforesubscribing to the pub/sub notification; if either is already present,
return immediately.
Motivation and Context
Found while debugging why
CmisManagerTasknever progressed past moduleinsertion on a switch where
xcvrdhad been restarted (without a fullconfig reload) during iterative bring-up of an 800G ZR+ coherent module.Confirmed via debug logging that the daemon printed "Waiting for
PortConfigDone..." once at startup and then produced no further output —
the notification had already occurred (
PORT_TABLE:PortConfigDoneexistedin APPL_DB the whole time), but the daemon had no way to notice.