Repository navigation
Adopt at most one stale link per UISP ID to tolerate MLO sublinks - #1144
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1144 +/- ##
==========================================
+ Coverage 95.00% 95.02% +0.02%
==========================================
Files 100 100
Lines 4605 4605
==========================================
+ Hits 4375 4376 +1
+ Misses 230 229 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| # stale row before the second ID gets its own match. Any | ||
| # remaining stale rows are handled by later iterations or the | ||
| # end-of-import inactive sweep. | ||
| existing_link = existing_links[0] |
There was a problem hiding this comment.
Is existing_links ordering ensured stable which would guarantee `existing_links[0] is the one we want to set in case of a change thereby reducing alerts?
There was a problem hiding this comment.
Here it doesn't matter because within this block we're already filtering for the relevant link UUID:
There was a problem hiding this comment.
As a sanity check I also added something to check the link type.
| ports: | ||
| - 5432:5432 | ||
| image: docker.io/postgres:15-bookworm | ||
| image: docker.io/postgres:17.11-trixie |
There was a problem hiding this comment.
Cheeky cheeky 😉 adding in infra changes without mention in the PR!
There was a problem hiding this comment.
bold of you to call docker-compose infra. This is for the dev setup. I was just trying to get the thing working. Apparently the meshdb container itself is using pg 17.11, but it's still talking to a pg 15.12 database 🤦🏻 so, this brings dev ever so slightly more in-line with reality.
| And if you have access to a database export, you can use the | ||
| [scripts/import_datadump.sh](scripts/import_datadump.sh) script to populate | ||
| your database | ||
| ### Loading a Database Export |
There was a problem hiding this comment.
Thank you! MOAR accurate docs for us noobs.
lotia
left a comment
There was a problem hiding this comment.
Only concern possibly misguided is here https://github.com/nycmeshnet/meshdb/pull/1144/changes#r4576472921
|
Good question. Ordering is deterministic via The fix doesn't change when the "possible duplicate objects" alert fires (still whenever |
When UISP reports two data-link objects for the same device pair (MLO sublinks with distinct UUIDs), the orphan-adoption fallback in import_and_sync_uisp_links re-points every stale MeshDB row to the first new ID processed in a single pass. The second ID then finds no stale rows remaining and creates a spurious extra Link. Fix: adopt at most one stale row per UISP link ID (existing_links[0] instead of iterating all). Prefer a type-matching stale row when types differ, falling back to the first row by UUID order. The end-of-import sweep marks any remaining stale rows INACTIVE. Adds test_import_and_sync_links_mlo_two_ids_same_device_pair covering the MLO multi-stale-row scenario.
Summary
When UISP reports two data-link objects for the same device pair (MLO sublinks with distinct UUIDs), the orphan-adoption fallback in
import_and_sync_uisp_linksre-points every stale MeshDB row to the first new ID processed in a single pass. The second ID then finds no stale rows remaining (they were all just re-pointed) and creates a spurious extraLink.Root cause
For MLO (2 UISP link IDs, same device pair):
uisp_idFix
Adopt at most one stale row per UISP link ID (use
existing_links[0]instead of iterating all). The end-of-import sweep handles marking any remaining stale rows INACTIVE.Steady state after fix
Tests
Added
test_import_and_sync_links_mlo_two_ids_same_device_paircovering the MLO multi-stale-row scenario.