Skip to content

Commit

Permalink
drop items when processing queue is full
Browse files Browse the repository at this point in the history
  • Loading branch information
somtochiama committed Aug 26, 2024
1 parent 8617910 commit 5ab85e9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/corro-agent/src/agent/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ pub async fn handle_changes(
agent.config().perf.apply_queue_timeout as u64,
));

const MAX_QUEUE_LEN: usize = 10000;
const MAX_SEEN_CACHE_LEN: usize = 10000;
const KEEP_SEEN_CACHE_SIZE: usize = 1000;
let mut seen: IndexMap<_, RangeInclusiveSet<CrsqlSeq>> = IndexMap::new();
Expand Down Expand Up @@ -861,6 +862,15 @@ pub async fn handle_changes(
continue;
}

// drop items when the queue is full.
if queue.len() > MAX_QUEUE_LEN {
warn!(
"dropping changes from {} because changes queue is full",
change.actor_id
);
continue;
}

if let Some(mut seqs) = change.seqs().cloned() {
let v = *change.versions().start();
if let Some(seen_seqs) = seen.get(&(change.actor_id, v)) {
Expand Down

0 comments on commit 5ab85e9

Please sign in to comment.