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

fix(base): Fix state events handling in sliding sync #4095

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Oct 8, 2024

Sliding sync expects all state events to be in required_state. State
events in timeline must be ignored. However, in sync v2, state
events in timeline must be handled.

Two patches:

  • From sliding sync response handler, we don't gather state events
    from timeline anymore,

  • In the same handler, both sliding sync and sync v2 uses the same
    handle_timeline method. I add an argument to ignore state
    events. This is not ideal, but it's a temporary solution as a first
    step. The next step is to refactor this code, but let's start easy.

Other patches updates the tests.

Next step: clean this flow/handler just like #4061 did.

Hywan added 2 commits October 8, 2024 16:25
With sliding sync, we must handle state events from `required_state`
only, not from `timeline`, this is a mistake as they might be incomplete
or _staled_.
Sliding sync expects all state events to be in `required_state`. State
events in `timeline` **must be ignored**. However, in sync v2, state
events in `timeline` **must be handled**.

In the sync response flow, both sliding sync and sync v2 uses the same
`handle_timeline` method. This patch adds an argument to ignore state
events. This is not ideal, but it's a temporary solution as a first
step. The next step is to refactor this code, but let's start easy.

The rest of the patch updates the tests accordingly.
@Hywan Hywan requested a review from a team as a code owner October 8, 2024 15:14
@Hywan Hywan requested review from andybalaam and poljar and removed request for a team and andybalaam October 8, 2024 15:14
@bnjbvr
Copy link
Member

bnjbvr commented Oct 9, 2024

For what it's worth: this patch breaks support for the sliding sync proxy, which behaves differently and expected that we did handle those timeline events, as far as I recall (hence the change in the test expectation you've tweaked). It might not be the first patch that did break the sliding sync proxy, but it's at least one. Should we merge it only when we officially deprecate support for the sliding sync proxy?

@poljar
Copy link
Contributor

poljar commented Oct 9, 2024

For what it's worth: this patch breaks support for the sliding sync proxy, which behaves differently and expected that we did handle those timeline events, as far as I recall (hence the change in the test expectation you've tweaked). It might not be the first patch that did break the sliding sync proxy, but it's at least one. Should we merge it only when we officially deprecate support for the sliding sync proxy?

Hmm, AFAIR we shouldn't handle state events for the proxy case either. I think this was raised multiple times, but we failed to do something about it. @kegsay could you please confirm or deny this?

Hywan added 3 commits October 9, 2024 12:07
To fix the `test_left_room`, we need to ask for the `m.room.member`
state event from `required_state`. The rest of the patch rewrites the
test a little bit to make it more Rust idiomatic.
To fix the `test_room_avatar_group_conversation`, we need to ask for the
`m.room.avatar` state event from `required_state`. The rest of the patch
rewrites the test a little bit to make it more Rust idiomatic.

The `response.rooms.*.avatar` field from sliding sync should contain the
new avatar, but for the moment, it doesn't. It seems to be a bug.
…` state.

This patch updates the `required_state` of `all_rooms` inside the
`RoomListService` to add `m.room.name`. Apparently, Synapse doesn't
always update the `response.rooms.*.avatar` field when the avatar is
updated. It's being investigated, but it doesn't hurt to ensure we get
it from the state events.
Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.68%. Comparing base (4bcb9b7) to head (658ec40).
Report is 30 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4095   +/-   ##
=======================================
  Coverage   84.67%   84.68%           
=======================================
  Files         269      269           
  Lines       28753    28741   -12     
=======================================
- Hits        24348    24339    -9     
+ Misses       4405     4402    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Hywan
Copy link
Member Author

Hywan commented Oct 9, 2024

Kegan has confirmed the proxy also requires to look inside the required_state only.

@@ -384,6 +384,7 @@ impl BaseClient {
room: &Room,
limited: bool,
events: Vec<Raw<AnySyncTimelineEvent>>,
ignore_state_events: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this boolean, but ok it's not as complex as I imagined it would be.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me neither! I'm gonna refactor this in a next PR (see the PR description where I already mention this).

@bnjbvr bnjbvr merged commit 22c765b into matrix-org:main Oct 10, 2024
40 checks passed
@Hywan Hywan mentioned this pull request Oct 22, 2024
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants