Skip to content

Commit 4615882

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

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ 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!(
150+
"Listed existing {} files, count = {}",
151+
name,
152+
existing_metastore_files.len()
153+
);
148154
let mut snapshot_map = HashMap::<u128, Vec<String>>::new();
149155
for existing in existing_metastore_files.into_iter() {
150156
let path = existing.split("/").nth(0).map(|p| {
@@ -197,10 +203,15 @@ impl BaseRocksStoreFs {
197203
return Ok(vec![]);
198204
}
199205

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

208+
let mut candidates_map = candidates_map;
202209
for ms in snapshots_list {
203-
to_delete.extend_from_slice(&candidates_map[&ms]);
210+
to_delete.append(
211+
candidates_map
212+
.get_mut(&ms)
213+
.expect("delete_old_snapshots candidates_map lookup should succeed"),
214+
);
204215
}
205216

206217
for batch in to_delete.chunks(

0 commit comments

Comments
 (0)