summaryrefslogtreecommitdiffstats
path: root/searchlib/src
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-06-12 06:54:55 +0000
committerArne Juul <arnej@verizonmedia.com>2020-06-12 08:36:29 +0000
commit7a01030e688079f7d1838c8d1f8b7384d1b98cdb (patch)
tree382da8869ac694d8790c022b2cc971941d1f5f7b /searchlib/src
parentd42fba42c3a8e58e87d3b03ad0124169c7b96e51 (diff)
no explicit clear of each level when removing document
* keep the levels as they were, so any concurrent search operation getting a reference to this docid can follow old links and avoid getting trapped if possible * ensure later GC can pick up any referenced data in HnswGraph::remove_node_for_document instead, it is more robust to have it in the graph layer anyway.
Diffstat (limited to 'searchlib/src')
-rw-r--r--searchlib/src/vespa/searchlib/tensor/hnsw_graph.cpp9
-rw-r--r--searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp2
2 files changed, 8 insertions, 3 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_graph.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_graph.cpp
index 69a1fbf2065..e47d1d8a48e 100644
--- a/searchlib/src/vespa/searchlib/tensor/hnsw_graph.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/hnsw_graph.cpp
@@ -37,9 +37,16 @@ void
HnswGraph::remove_node_for_document(uint32_t docid)
{
auto node_ref = node_refs[docid].load_acquire();
- nodes.remove(node_ref);
+ assert(node_ref.valid());
+ auto levels = nodes.get(node_ref);
vespalib::datastore::EntryRef invalid;
node_refs[docid].store_release(invalid);
+ // Ensure data referenced through the old ref can be recycled:
+ nodes.remove(node_ref);
+ for (size_t i = 0; i < levels.size(); ++i) {
+ auto old_links_ref = levels[i].load_acquire();
+ links.remove(old_links_ref);
+ }
}
void
diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp
index 9382fef13f6..7d800be428e 100644
--- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp
@@ -400,7 +400,6 @@ void
HnswIndex::remove_document(uint32_t docid)
{
bool need_new_entrypoint = (docid == get_entry_docid());
- LinkArray empty;
LevelArrayRef node_levels = _graph.get_level_array(docid);
for (int level = node_levels.size(); level-- > 0; ) {
LinkArrayRef my_links = _graph.get_link_array(docid, level);
@@ -413,7 +412,6 @@ HnswIndex::remove_document(uint32_t docid)
remove_link_to(neighbor_id, docid, level);
}
mutual_reconnect(my_links, level);
- _graph.set_link_array(docid, level, empty);
}
if (need_new_entrypoint) {
HnswGraph::EntryNode entry;