Skip to content

Commit 0b0b6e1

Browse files
fix(server): clear cell index state during nuke
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 7b8cd6a commit 0b0b6e1

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

HTTP_API.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ Response:
8787
"scanned_schemas": 12,
8888
"removed_vertices": 120,
8989
"removed_cells": 842,
90-
"removed_schemas": 0
90+
"removed_schemas": 0,
91+
"cleared_cell_index_entries": 962
9192
}
9293
}
9394
```

crates/morpheus-http-client/src/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub struct NukeResult {
1212
pub removed_vertices: usize,
1313
pub removed_cells: usize,
1414
pub removed_schemas: usize,
15+
pub cleared_cell_index_entries: usize,
1516
}
1617

1718
#[derive(Debug, Deserialize, Serialize)]

crates/morpheus-http-client/tests/http_gateway_e2e.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ async fn http_gateway_client_full_e2e() {
549549
let nuke = client.nuke().await.expect("admin nuke").data;
550550
assert!(nuke.scanned_schemas > 0);
551551
assert_eq!(nuke.removed_schemas, 0);
552+
assert!(nuke.cleared_cell_index_entries >= nuke.removed_cells);
552553

553554
let schema_nuke = client.nuke_schema().await.expect("admin nuke schema").data;
554555
assert!(schema_nuke.scanned_schemas > 0);

src/server/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::server::schema::GraphSchema;
1919
use crate::server::schema::SchemaContainer;
2020
use crate::traversal::compute::ComputeService;
2121
use crate::traversal::expand::distributed::ExpandService;
22+
use neb::index::builder::IndexBuilder;
2223
use neb::ram::cell::WriteError;
2324
use neb::ram::schema::DelSchemaError;
2425
use neb::ram::types::Id;
@@ -71,6 +72,7 @@ pub struct NukeResult {
7172
pub removed_vertices: usize,
7273
pub removed_cells: usize,
7374
pub removed_schemas: usize,
75+
pub cleared_cell_index_entries: usize,
7476
}
7577

7678
#[derive(Debug, Serialize, Deserialize, Clone)]
@@ -437,11 +439,18 @@ impl MorpheusServer {
437439
}
438440
}
439441

442+
if self.neb_server.indexer.is_some() {
443+
let _ = IndexBuilder::await_all_indices().await;
444+
}
445+
446+
let cleared_cell_index_entries = self.neb_server.chunks.clear_cell_index();
447+
440448
Ok(NukeResult {
441449
scanned_schemas: schemas.len(),
442450
removed_vertices,
443451
removed_cells,
444452
removed_schemas: 0,
453+
cleared_cell_index_entries,
445454
})
446455
}
447456

0 commit comments

Comments
 (0)