Skip to content

fix: avoid blocking SMD cache during update - #122

Merged
travisbcotton merged 1 commit into
mainfrom
121-bug-bug
Aug 3, 2026
Merged

fix: avoid blocking SMD cache during update#122
travisbcotton merged 1 commit into
mainfrom
121-bug-bug

Conversation

@alexlovelltroy

Copy link
Copy Markdown
Member

Description

This pull request refactors the PopulateNodes method in SMDclient.go to improve thread safety and atomicity of updates, ensuring that cached lookups and modifications are not blocked by slow network operations. Additionally, a new performance test is added to verify that cache operations remain non-blocking during slow refreshes.

Thread safety and atomicity improvements:

  • Refactored PopulateNodes to build new maps (nextNodes, nextIPToXname, etc.) off-lock, and only acquire the write lock briefly to atomically swap in the new state, preventing cache lookups from being blocked by network I/O. [1] [2]

Testing enhancements:

  • Added a new test, TestPopulateNodesBlockedRefreshDoesNotBlockCachedOperations, to ensure that cached methods like IDfromIP and AddWGIP remain responsive even when PopulateNodes is blocked on a network call.

Checklist

  • My code follows the style guidelines of this project
  • I have added/updated comments where needed
  • I have added tests that prove my fix is effective or my feature works
  • I have run make test (or equivalent) locally and all tests pass
  • I have updated the relevant documentation (CLI examples, man pages, README, other docs, etc.)
  • DCO Sign-off: All commits are signed off (git commit -s) with my real name and email
  • REUSE Compliance:
    • Each new/modified source file has SPDX copyright and license headers
    • Any non-commentable files include a <filename>.license sidecar
    • All referenced licenses are present in the LICENSES/ directory

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Dependency update

For more info, see Contributing Guidelines.

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
@alexlovelltroy alexlovelltroy linked an issue Aug 3, 2026 that may be closed by this pull request
1 task

@travisbcotton travisbcotton left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me

@travisbcotton
travisbcotton merged commit 7fc1492 into main Aug 3, 2026
5 checks passed
@synackd
synackd deleted the 121-bug-bug branch August 3, 2026 23:26
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.

[Bug]: BUG

2 participants