Skip to content

Commit

Permalink
[BUG] Add check for empty memberlist for compactor scheduler (#1998)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - This PR adds check for empty memberlist. 
 - New functionality
	 - ...

## Test plan
*How are these changes tested?*

- [ ] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
  • Loading branch information
Ishiihara authored Apr 10, 2024
1 parent 983770f commit c8f8888
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rust/worker/src/compactor/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ impl Scheduler {
}

pub(crate) async fn schedule(&mut self) {
if self.memberlist.is_none() {
if self.memberlist.is_none() || self.memberlist.as_ref().unwrap().is_empty() {
// TODO: Log error
println!("Memberlist is not set");
println!("Memberlist is not set or empty. Cannot schedule compaction jobs.");
return;
}
let collections = self.get_collections_with_new_data().await;
Expand Down Expand Up @@ -262,6 +262,13 @@ mod tests {
let jobs = scheduler.get_jobs();
assert_eq!(jobs.count(), 0);

// Set empty memberlist
// Scheduler does nothing with empty memberlist
scheduler.set_memberlist(vec![]);
scheduler.schedule().await;
let jobs = scheduler.get_jobs();
assert_eq!(jobs.count(), 0);

// Set memberlist
scheduler.set_memberlist(vec![my_ip.clone()]);
scheduler.schedule().await;
Expand Down

0 comments on commit c8f8888

Please sign in to comment.