Skip to content

Commit 078563c

Browse files
committed
chore(cubestore): Make delete_old_snapshots having logging, avoid additional memory use
1 parent 6c376a5 commit 078563c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

rust/cubestore/cubestore/src/metastore/rocks_fs.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ impl BaseRocksStoreFs {
145145
name: &str,
146146
) -> Result<HashMap<u128, Vec<String>>, CubeError> {
147147
let existing_metastore_files = remote_fs.list(format!("{}-", name)).await?;
148+
// Log a debug statement so that we can rule out the filename list itself being too large for memory.
149+
log::debug!("Listed existing {} files, count = {}", name, existing_metastore_files.len());
148150
let mut snapshot_map = HashMap::<u128, Vec<String>>::new();
149151
for existing in existing_metastore_files.into_iter() {
150152
let path = existing.split("/").nth(0).map(|p| {
@@ -197,10 +199,11 @@ impl BaseRocksStoreFs {
197199
return Ok(vec![]);
198200
}
199201

200-
let mut to_delete = Vec::new();
202+
let mut to_delete: Vec<String> = Vec::new();
201203

204+
let mut candidates_map = candidates_map;
202205
for ms in snapshots_list {
203-
to_delete.extend_from_slice(&candidates_map[&ms]);
206+
to_delete.append(candidates_map.get_mut(&ms).expect("delete_old_snapshots candidates_map lookup should succeed"));
204207
}
205208

206209
for batch in to_delete.chunks(

0 commit comments

Comments
 (0)