Skip to content

Fix Netmap crash on oversized cache objects#3795

Merged
lunkwill42 merged 2 commits into5.17.xfrom
bugfix/netmap-no-fail-on-cache-errors
Feb 19, 2026
Merged

Fix Netmap crash on oversized cache objects#3795
lunkwill42 merged 2 commits into5.17.xfrom
bugfix/netmap-no-fail-on-cache-errors

Conversation

@lunkwill42
Copy link
Copy Markdown
Member

Scope and purpose

Fixes a production crash where Netmap returns a 500 error when the layer 2 topology graph exceeds memcached's default max item size (1MB). The MemcacheServerError: b'object too large for cache' exception propagated up from cache.set() even though the graph data was computed successfully.

This pull request

  • adds/changes/removes a dependency
  • changes the database
  • changes the API

Contributor Checklist

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • Wrote the commit message so that the first line continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • Based this pull request on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If it's not obvious from a linked issue, described how to interact with NAV in order for a reviewer to observe the effects of this change first-hand (commands, URLs, UI interactions)
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this adds a new Python source code file: Added the boilerplate header to that file

@lunkwill42 lunkwill42 self-assigned this Feb 18, 2026
@lunkwill42 lunkwill42 requested a review from a team February 18, 2026 09:09
Large topology graphs can exceed memcached's default 1MB item
size limit, causing `cache.set()` to raise `MemcacheServerError`.
This crashed the request even though the data was computed
successfully.

Wrap all `cache.set()` calls in `_safe_cache_set()` that catches
exceptions and logs a warning, returning the response uncached
rather than failing with a 500 error.
@lunkwill42 lunkwill42 force-pushed the bugfix/netmap-no-fail-on-cache-errors branch from 58c4c7a to d9a5c39 Compare February 18, 2026 09:15
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Test results

    20 files      20 suites   25m 0s ⏱️
 2 869 tests  2 869 ✅ 0 💤 0 ❌
16 386 runs  16 386 ✅ 0 💤 0 ❌

Results for commit d9a5c39.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 63.38%. Comparing base (e90b3a1) to head (d9a5c39).
⚠️ Report is 11 commits behind head on 5.17.x.

Files with missing lines Patch % Lines
python/nav/web/netmap/cache.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           5.17.x    #3795      +/-   ##
==========================================
+ Coverage   63.33%   63.38%   +0.04%     
==========================================
  Files         619      619              
  Lines       45875    45882       +7     
  Branches       43       43              
==========================================
+ Hits        29057    29083      +26     
+ Misses      16808    16789      -19     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lunkwill42 lunkwill42 merged commit 6a64534 into 5.17.x Feb 19, 2026
19 checks passed
@lunkwill42 lunkwill42 deleted the bugfix/netmap-no-fail-on-cache-errors branch February 19, 2026 11:54
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