Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pubsub: fix catch up logic #242

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion crates/corro-agent/src/api/public/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ pub async fn catch_up_sub(
}
};

let min_change_id = last_change_id + 1;
let mut min_change_id = last_change_id + 1;
info!(sub_id = %matcher.id(), "minimum expected change id: {min_change_id:?}");

let mut pending_event = None;
Expand Down Expand Up @@ -522,6 +522,8 @@ pub async fn catch_up_sub(
if let Some(change_id) = last_sub_change_id {
debug!(sub_id = %matcher.id(), "got a change to check: {change_id:?}");
for i in 0..5 {
min_change_id = last_change_id + 1;

if change_id > min_change_id {
// missed some updates!
info!(sub_id = %matcher.id(), "attempt #{} to catch up subcription from change id: {change_id:?} (last: {last_change_id:?})", i+1);
Expand Down Expand Up @@ -569,6 +571,8 @@ pub async fn catch_up_sub(
warn!(sub_id = %matcher.id(), "could not send buffered events to subscriber, receiver must be gone!");
return;
}

last_change_id = change_id;
}
}

Expand All @@ -586,6 +590,8 @@ pub async fn catch_up_sub(
warn!(sub_id = %matcher.id(), "could not send buffered events to subscriber, receiver must be gone!");
return;
}

last_change_id = change_id;
}
}

Expand Down
Loading