This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make get_room_version use cached get_room_version_id. #11808
Make get_room_version use cached get_room_version_id. #11808
Changes from 5 commits
ea23217
397459e
1852397
73ffce1
3ca4687
2d33cbc
8b63570
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why is this needed?
It's bad practice to add invalidations for the tests since it might cover up an invalidation problem in the real code (I ran into this too during one of my recent PRs).
It's not clear to my why it's needed in the first place, but ideally we should fix it so it's not needed, or failing that, add a comment about it?
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.
The test tests whether a room summary still succeeds, even if the room's version is invalid. To do so, it sets the room version id to
unknown-room-version
in the lines above. However the room version has already been requested before. Therefore,get_room_version
will not returnunknown-room-version
as the room version forroom_id
. Hence,get_room_version
's cache must be invalidated.I actually included a comment now.
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.
What is weird though, is that removing these lines
synapse/tests/handlers/test_room_summary.py
Lines 722 to 729 in 3655585
(and not invalidating
get_version_id
) results in a different exception than including the above lines (and not invalidatingget_version_id
). However, in both cases,get_version_id
returns the same, namely'6'
. However, I would expect both scenarios would result in the same exception. @reivilibre Do you have any idea why this could be the case? Should I dig more deeply into the reasons?The first approach fails here
synapse/tests/handlers/test_room_summary.py
Line 734 in 3655585
with
while the latter fails here
synapse/tests/handlers/test_room_summary.py
Line 731 in 3655585
with
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.
Looking at this one, it seems like it occurs because the event fetching code fetches the room version separately and then encounters a room version it doesn't understand: it then skips fetching that event. (This is a design choice: events in unknown room versions are treated as nonexistent events because we don't know how to decode them)
I think that's fine; in practice the version of a room doesn't change and so there's no way the cache would get out of sync with the database.
This is happening because if you don't set the room version to something unknown, the code will (correctly) generate a room summary entry for it, which the test doesn't expect for unknown room versions.
I think your code is therefore fine as-is!