feat(hgraph): add support_force_remove switch#2086
Conversation
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Require kind labelWonderful, this rule succeeded.
🟢 Require version labelWonderful, this rule succeeded.
🟢 Require linked issue for feature/bug PRsWonderful, this rule succeeded.
|
There was a problem hiding this comment.
Pull request overview
Adds a dedicated support_force_remove build parameter for HGraph and threads it through constants → external/internal parameter mapping → runtime behavior, so RemoveMode::FORCE_REMOVE and its extra synchronization are explicitly opt-in and no longer conflated with support_remove (delete-tracking metadata).
Changes:
- Introduce/export
support_force_removein public/internal constants and map it intoHGraphParameter. - Gate force-remove locking and
RemoveMode::FORCE_REMOVEbehindsupport_force_remove, while keepingsupport_removefor delete-tracking metadata semantics. - Update unit/functional tests, examples, and EN/ZH docs to reflect the split behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_hgraph_remove.cpp |
Allows building HGraph with/without support_force_remove and adds a regression test for FORCE_REMOVE guard rails. |
src/inner_string_params.h |
Adds internal string key for support_force_remove and wires it into the default placeholder map. |
src/constants.cpp |
Exports the new public constant string HGRAPH_SUPPORT_FORCE_REMOVE. |
include/vsag/constants.h |
Declares the new public constant HGRAPH_SUPPORT_FORCE_REMOVE. |
src/algorithm/hgraph_parameter.h |
Adds support_force_remove to the HGraph parameter struct. |
src/algorithm/hgraph_parameter.cpp |
Parses/serializes/compat-checks support_force_remove. |
src/algorithm/hgraph_parameter_test.cpp |
Extends compatibility and mapping tests for the new parameter. |
src/algorithm/hgraph.h |
Stores and exposes support_force_remove on the HGraph instance. |
src/algorithm/hgraph.cpp |
Maps the new external param, gates FORCE_REMOVE & locking, and adjusts add/code-insertion locking behavior. |
examples/cpp/303_feature_remove.cpp |
Updates example build JSON to use support_force_remove. |
docs/hgraph.md |
Documents the split between support_remove and support_force_remove and updates examples. |
docs/docs/en/src/indexes/hgraph.md |
Updates English HGraph parameter docs to describe the split. |
docs/docs/zh/src/indexes/hgraph.md |
Updates Chinese HGraph parameter docs to describe the split. |
docs/docs/en/src/advanced/index_lifecycle.md |
Updates lifecycle docs for FORCE_REMOVE gating. |
docs/docs/zh/src/advanced/index_lifecycle.md |
Updates lifecycle docs for FORCE_REMOVE gating. |
Comments suppressed due to low confidence (1)
src/algorithm/hgraph.cpp:1842
insert_persistent_codes()no longer takes any lock onadd_mutex_(it’s commented out). This function is called from the parallel code-insertion path inAdd()(deferred persistent codes) and can also overlap with other concurrentAdd()calls, so removing the lock can introduce data races. GivenFlattenDataCellis explicitly marked "thread unsafe" (src/datacell/flatten_datacell.h) andInsertVector()isn’t fully synchronized, please restore proper synchronization here (e.g., guardInsertVectorcalls withadd_mutex_, likely an exclusive lock), or otherwise make the underlying code insertion path thread-safe.
HGraph::insert_persistent_codes(const void* data, InnerIdType inner_id) {
// std::shared_lock add_lock(add_mutex_);
this->basic_flatten_codes_->InsertVector(data, inner_id);
if (has_precise_reorder()) {
this->high_precise_codes_->InsertVector(data, inner_id);
}
There was a problem hiding this comment.
Code Review
This pull request introduces a new configuration parameter, support_force_remove, to the HGraph index to explicitly control the availability of the FORCE_REMOVE deletion mode. The changes include updating the index parameter mapping, adding the necessary flag to the HGraph implementation, and updating documentation and tests to reflect this requirement. A potential concurrency issue was identified regarding the commented-out add_mutex_ lock in insert_persistent_codes, which requires further investigation to ensure thread safety.
|
@gemini-code-assist The comment about the commented-out void HGraph::insert_persistent_codes(const void* data, InnerIdType inner_id) {
std::shared_lock<std::shared_mutex> add_lock;
if (not this->support_force_remove()) {
add_lock = std::shared_lock<std::shared_mutex>(this->add_mutex_);
}
// ... insertion code ...
}When
When
Regarding the |
|
Thank you for the detailed clarification regarding the lock conditionization in |
- add a dedicated support_force_remove HGraph parameter and map it through the public and internal parameter layers - gate force-remove locking and RemoveMode::FORCE_REMOVE on support_force_remove while keeping support_remove for existing delete-metadata semantics - update regression tests, examples, and EN/ZH docs to describe the split behavior Closes: #2085 Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
Summary
support_force_removeHGraph parameter and map it through the public and internal parameter layersRemoveMode::FORCE_REMOVEonsupport_force_removewhile keepingsupport_removefor existing delete-metadata semanticsVerification
cmake -S . -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ONcmake --build build-release --target functests unittests./build-release/tests/unittests "*support_force_remove*"./build-release/tests/functests "HGraph ForceRemove Requires support_force_remove"Closes: #2085