Skip to content

Commit 4487dfa

Browse files
committed
[ENH] Tie the wal3 garbage collector into the garbage collection service.
What's done: - Garbage collection in steady state will use the tested path. What's undone: - Hard delete of collections need to wipe things off the face of the S3.
1 parent 4ea5072 commit 4487dfa

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/garbage_collector/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ chroma-cache = { workspace = true }
4646
chroma-index = { workspace = true }
4747
chroma-memberlist = { workspace = true }
4848
chroma-tracing = { workspace = true }
49+
wal3 = { workspace = true }
4950

5051
[dev-dependencies]
5152
proptest = { workspace = true }

rust/garbage_collector/src/garbage_collector_orchestrator_v2.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::sync::Arc;
2+
13
use crate::construct_version_graph_orchestrator::{
24
ConstructVersionGraphError, ConstructVersionGraphOrchestrator,
35
};
@@ -44,6 +46,7 @@ use std::time::SystemTime;
4446
use thiserror::Error;
4547
use tokio::sync::oneshot::{error::RecvError, Sender};
4648
use tracing::Span;
49+
use wal3::{GarbageCollectionOptions, LogWriter, LogWriterOptions};
4750

4851
#[derive(Debug)]
4952
pub struct GarbageCollectorOrchestrator {
@@ -280,6 +283,31 @@ impl GarbageCollectorOrchestrator {
280283

281284
let collection_ids = output.version_files.keys().cloned().collect::<Vec<_>>();
282285

286+
for collection_id in collection_ids.iter() {
287+
let log = match LogWriter::open(
288+
LogWriterOptions::default(),
289+
Arc::new(self.storage.clone()),
290+
&collection_id.storage_prefix_for_log(),
291+
"garbage collection service",
292+
(),
293+
)
294+
.await
295+
{
296+
Ok(log) => log,
297+
Err(err) => {
298+
tracing::error!("could not garbage collect log: {err:?}");
299+
continue;
300+
}
301+
};
302+
if let Err(err) = log
303+
.garbage_collect(&GarbageCollectionOptions::default())
304+
.await
305+
{
306+
tracing::error!("could not garbage collect log: {err:?}");
307+
continue;
308+
}
309+
}
310+
283311
self.soft_deleted_collections_to_gc = self
284312
.get_eligible_soft_deleted_collections_to_gc(collection_ids)
285313
.await?;
@@ -813,6 +841,7 @@ impl GarbageCollectorOrchestrator {
813841
);
814842

815843
for collection_id in ordered_soft_deleted_to_hard_delete_collections {
844+
// TODO(rescrv): add wal3 hard delete here.
816845
self.sysdb_client
817846
.finish_collection_deletion(
818847
self.tenant

0 commit comments

Comments
 (0)