Skip to content

Commit

Permalink
log line every power of 10 to avoid spamming
Browse files Browse the repository at this point in the history
  • Loading branch information
somtochiama committed Aug 21, 2024
1 parent 425e3d0 commit c9c2f3d
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions crates/corro-agent/src/agent/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ pub async fn handle_changes(
const KEEP_SEEN_CACHE_SIZE: usize = 1000;
let mut seen: IndexMap<_, RangeInclusiveSet<CrsqlSeq>> = IndexMap::new();

let mut drop_log_count: u64 = 0;
// complicated loop to process changes efficiently w/ a max concurrency
// and a minimum chunk size for bigger and faster SQLite transactions
loop {
Expand Down Expand Up @@ -841,10 +842,17 @@ pub async fn handle_changes(

// 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
);
drop_log_count += 1;
if is_pow_10(drop_log_count) {
if drop_log_count == 1 {
warn!("dropping a change because changes queue is full");
} else {
warn!(
"dropping {} changes because changes queue is full",
drop_log_count
);
}
}
continue;
}

Expand Down Expand Up @@ -1124,3 +1132,11 @@ mod tests {
Ok(())
}
}

#[inline]
fn is_pow_10(i: u64) -> bool {
matches!(
i,
1 | 10 | 100 | 1000 | 10000 | 1000000 | 10000000 | 100000000
)
}

0 comments on commit c9c2f3d

Please sign in to comment.