-
Notifications
You must be signed in to change notification settings - Fork 74
Fix fork state after recovery is successful #2706
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
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd the label mergequeue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
I'll analyze this and get back to you. |
8aa78eb to
b06561a
Compare
b06561a to
df6dab3
Compare
Fix commit log fork after readd by resetting visible commits at the latest
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2706 +/- ##
=======================================
Coverage 77.50% 77.50%
=======================================
Files 367 367
Lines 53872 53907 +35
=======================================
+ Hits 41753 41782 +29
- Misses 12119 12125 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| )); | ||
| } | ||
| let after_cursor = after_cursor as i32; | ||
| let latest_welcome_rowid: Option<i32> = self.raw_query_read(|db| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after_cursor as i32 + 1 can overflow when after_cursor == i32::MAX, causing panic or wrong filtering. Consider avoiding the addition: if no Welcome is found, use dsl::rowid.gt(after_cursor as i32); otherwise use dsl::rowid.ge(latest_welcome_rowid).
- let latest_welcome_rowid: Option<i32> = self.raw_query_read(|db| {
+ let latest_welcome_rowid: Option<i32> = self.raw_query_read(|db| {
dsl::local_commit_log
.select(diesel::dsl::max(dsl::rowid))
.filter(dsl::group_id.eq(group_id))
.filter(dsl::rowid.gt(after_cursor as i32))
.filter(dsl::commit_type.eq(Some("Welcome".to_string())))
.first(db)
})?;
- let gte_cursor = latest_welcome_rowid.unwrap_or(after_cursor as i32 + 1);
-
- let query = dsl::local_commit_log
- .filter(dsl::group_id.eq(group_id))
- .filter(dsl::rowid.ge(gte_cursor))
- .filter(dsl::commit_sequence_id.ne(0));
+ let base_query = dsl::local_commit_log
+ .filter(dsl::group_id.eq(group_id))
+ .filter(dsl::commit_sequence_id.ne(0));
+
+ let query = if let Some(welcome_rowid) = latest_welcome_rowid {
+ base_query.filter(dsl::rowid.ge(welcome_rowid))
+ } else {
+ base_query.filter(dsl::rowid.gt(after_cursor as i32))
+ };
let rows = self.raw_query_read(|db| match order {
LocalCommitLogOrder::AscendingByRowid => query.order_by(dsl::rowid.asc()).load(db),
LocalCommitLogOrder::DescendingByRowid => query.order_by(dsl::rowid.desc()).load(db),
})?;
Ok(rows)🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
| .filter(dsl::commit_type.eq(Some("Welcome".to_string()))) | ||
| .first(db) | ||
| })?; | ||
| let gte_cursor = latest_welcome_rowid.unwrap_or(after_cursor as i32 + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could use saturating add even though it's unlikely to ever get that far.


This fixes an issue found via @cameronvoell's validation: after a forked client successfully recovers from their forked state, they seem to remain evaluating themselves as forked, and continue to issue re-add requests with each worker iteration after that.
There are two fixes here:
readd_status, but also theis_forkedflag. This fixes the bulk of the issue.Also included an end-to-end unit test that validates both of these fixes (fails without either one of the fixes).
(1) was not previously mentioned in the XIP, also updated it to include this.