This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Make get_room_version use cached get_room_version_id. #11808
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ea23217
let get_room_version use cached get_room_version_id
lukasdenk 397459e
Add Changelog
lukasdenk 1852397
Add "await" to method call
lukasdenk 73ffce1
rename private method to 1 preceeding "_"
lukasdenk 3ca4687
invalidate cache in SpaceSummaryTestCase.test_unknown_room_version
lukasdenk 2d33cbc
convert method to function
lukasdenk 8b63570
add comment to explain cache invalidation in test
lukasdenk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Make method `get_room_version` use cached `get_room_version_id`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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!