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

feat(sdk): Sliding sync has a timeout if all lists require a timeout #3853

Merged
merged 6 commits into from
Aug 21, 2024

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Aug 19, 2024

This patch updates when sliding sync requests have a timeout.

Prior to this patch, all requests had a timeout query, set to the
poll_timeout duration value. However it means: if there is no data
to return, wait timeout milliseconds for new data before returning.
This definition is correct. Problem: if the current range of a list
has no data, the server will wait! It means that, in a situation where
there is no update at all, but the client is fetching all rooms batch by
batch, it will wait poll_timeout for each batch!

The behaviour described above is absolutely correct. Some server
implementations are less strict though, and we didn't realise our code
was doing that, because the server had some optimisations to ignore the
timeout if the range wasn't covering all the rooms. Nonetheless, a new
server implementation (namely Synapse) is strict, and it confirms we
have a bug here.

This patch then configures a timeout if all lists require a timeout,
otherwise there is no timeout, which is equivalent to timeout=0.


This patch renames tests.
This patch implements and tests
`SlidingSyncListLoadingState::is_fully_loaded` for more convenience.
@Hywan Hywan requested a review from a team as a code owner August 19, 2024 10:17
@Hywan Hywan requested review from stefanceriu and bnjbvr and removed request for a team and stefanceriu August 19, 2024 10:17
Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.10%. Comparing base (711a753) to head (a84c172).
Report is 29 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3853   +/-   ##
=======================================
  Coverage   84.09%   84.10%           
=======================================
  Files         262      262           
  Lines       27646    27657   +11     
=======================================
+ Hits        23249    23261   +12     
+ Misses       4397     4396    -1     

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

@Hywan Hywan changed the title feat(sdk): Sliding sync has a timeout if all lists are fully loaded feat(sdk): Sliding sync has a timeout if all lists require a timeout Aug 19, 2024
@Hywan Hywan mentioned this pull request Aug 19, 2024
32 tasks
Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

I'd have wished the last 3 commits would be squashed into 59324a6, since they all update the logic introduced in that commit, and having them as separate commits makes the review somewhat harder. LGTM otherwise, assuming my comments will be addressed.

crates/matrix-sdk/src/sliding_sync/mod.rs Outdated Show resolved Hide resolved
crates/matrix-sdk/src/sliding_sync/mod.rs Outdated Show resolved Hide resolved
crates/matrix-sdk/src/sliding_sync/mod.rs Outdated Show resolved Hide resolved
This patch adds a small helper:
`SlidingSyncListRequestGenerator::is_selective`.
This patchs adds the `SlidingSyncList::requires_timeout` method to know
exactly when a list should trigger a `timeout` on the request.
@Hywan Hywan force-pushed the feat-sdk-sliding-sync-timeout branch from 6f4e062 to ddc8957 Compare August 21, 2024 08:47
This patch updates when sliding sync requests have a `timeout`.

Prior to this patch, all requests had a `timeout` query, set to the
`poll_timeout` duration value. However it means: if there is no data
to return, wait `timeout` milliseconds for new data before returning.
This definition is correct. Problem: if the current range of a list
has no data, the server will wait! It means that, in a situation where
there is no update at all, but the client is fetching all rooms batch by
batch, it will wait `poll_timeout` for each batch!

The behaviour described above is absolutely correct. Some server
implementations are less strict though, and we didn't realise our code
was doing that, because the server had some optimisations to ignore the
timeout if the range wasn't covering all the rooms. Nonetheless, a new
server implementation (namely Synapse) is strict, and it confirms we
have a bug here.

This patch then configures a `timeout` if all lists require a timeout,
otherwise there is no `timeout`, which is equivalent to `timeout=0`.
@Hywan Hywan force-pushed the feat-sdk-sliding-sync-timeout branch from ddc8957 to a84c172 Compare August 21, 2024 08:50
@Hywan Hywan enabled auto-merge (rebase) August 21, 2024 08:50
@Hywan Hywan disabled auto-merge August 21, 2024 11:11
@Hywan Hywan merged commit f6b21e6 into matrix-org:main Aug 21, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants