-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fixup on https://github.com/matrix-org/matrix-rust-sdk/pull/3995 #2
base: recovering
Are you sure you want to change the base?
Conversation
@@ -127,8 +155,6 @@ impl StateMachine { | |||
} | |||
}; | |||
|
|||
self.set(next_state.clone()); |
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.
That's one bug.
@@ -97,9 +122,12 @@ impl StateMachine { | |||
} | |||
|
|||
Running => { | |||
// We haven't sync for a while so we should go back to recovering | |||
if self.last_sync_date.elapsed() > self.delay_before_recover { | |||
// We haven't changed the state for a while, we go back to `Recovering` to avoid |
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.
Let's not talk about sync but rather about state update here. A sync happens in RoomListService
, not here.
pub(super) fn set(&self, state: State) { | ||
self.current.set(state); | ||
let mut last_state_update_time = self.last_state_update_time.lock().unwrap(); |
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.
That's one bug fix. Updating the state must reset last_state_update_time
.
/// The maximum time before considering the state as “too old”. | ||
/// | ||
/// To be used in coordination with `Self::last_state_update_time`. | ||
state_lifespan: Duration, |
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.
I believe this naming conveys a better semantics.
state_machine.set(state_machine.next(sliding_sync).await?); | ||
assert_eq!(state_machine.get(), State::Running); | ||
} |
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.
Testing we are still in Running
reveals one of the bug.
These patch fixes your
recovering
branch. Once merged, please rebase all the commits, maybe in a single commit as there isn't too much code.Sorry for the messy commits, but it would be better if I could rebase with your branch 😉.
Instant
is never updated!StateMachine::next
must not update the state, it must just calculated the next one