Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix limit logic for AccountDataStream #7384

Merged
merged 7 commits into from
May 15, 2020
Merged

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Apr 30, 2020

Make sure that the AccountDataStream presents complete updates, in the right
order.

This is much the same fix as #7337 and #7358, but applied to a different stream.

@richvdh richvdh requested a review from a team May 5, 2020 13:21

room_rows = (
(stream_id, (user_id, room_id, account_data_type))
for stream_id, user_id, room_id, account_data_type in room_results
Copy link
Member

Choose a reason for hiding this comment

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

I know that technically this doesn't need a if stream_id <= token clause, but I think adding may make it less confusing why we're omitting it (or add a comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I added a comment.

return results
# we need to return a sorted list, so merge them together.
updates = list(heapq.merge(room_rows, global_rows))
return updates, to_token, limited
Copy link
Member

Choose a reason for hiding this comment

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

Any reason not to move some of this handling into the store? I'm mainly thinking it might be more efficient that way, if for no other reason that we would only need one transaction rather than two.

Copy link
Member Author

Choose a reason for hiding this comment

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

I dunno, maybe?

It feels like that would be a different approach to that taken by all the other stream sources: it would mean we'd have to mess about with limited inside the store, which normally we don't do.

Another way would be to follow the example of get_all_device_list_changes_for_remotes and do one query with a UNION, but I only found that after I wrote this stuff...

@richvdh richvdh merged commit 6c1f7c7 into develop May 15, 2020
@richvdh richvdh deleted the rav/fix_account_data_catchup branch May 15, 2020 18:03
phil-flex pushed a commit to phil-flex/synapse that referenced this pull request Jun 16, 2020
Make sure that the AccountDataStream presents complete updates, in the right
order.

This is much the same fix as matrix-org#7337 and matrix-org#7358, but applied to a different stream.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants