Skip to content

fix(test): add scope guard for logger sink cleanup in dynamic index tests - #471

Open
rfsaliev wants to merge 1 commit into
mainfrom
rfsaliev/fix-log-sink-in-test
Open

rfsaliev wants to merge 1 commit into
mainfrom
rfsaliev/fix-log-sink-in-test

Conversation

@rfsaliev

Copy link
Copy Markdown
Member

This pull request makes improvements to logging resource management in the test suite for the Vamana dynamic index. The main change is the introduction of a scope guard to ensure that a locally-captured logging sink is properly removed before the associated vector goes out of scope, preventing potential resource leaks or invalid accesses.

Resource management improvements:

  • Added #include "svs/lib/scopeguard.h" to dynamic_index_2.cpp to enable use of scope guards for automatic resource cleanup.
  • In both the "Testing Graph Index" and "Dynamic MutableVamanaIndex Per-Index Logging Test" test cases in dynamic_index_2.cpp, wrapped the addition of global_callback_sink to the logger with a scope guard (svs::lib::make_scope_guard) to ensure the sink is removed from the logger's sinks vector when the test scope ends. [1] [2]

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the test logging sink cleanup change.

No open issues 🎉

What changed in this PR

Improves logging cleanup in the Vamana dynamic index tests by removing callback sinks before the local vectors they capture are destroyed, preventing potential invalid accesses.

Changes:

  • Adds the scope guard header.
  • Adds automatic sink cleanup to both “Testing Graph Index” and “Dynamic MutableVamanaIndex Per-Index Logging Test,” including during exception unwinding.
File Description
tests/​svs/​index/​vamana/​dynamic_index_2.cpp Uses scope guards to remove both tests’ callback sinks before their captured data goes out of scope.

Review effort: Balanced

This branch has not been deployed

No deployments
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