Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
8e56a1b7
Unverified
Commit
8e56a1b7
authored
3 years ago
by
lukasdenk
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make get_room_version use cached get_room_version_id. (#11808)
parent
5f62a094
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/11808.misc
+1
-0
1 addition, 0 deletions
changelog.d/11808.misc
synapse/storage/databases/main/state.py
+13
-14
13 additions, 14 deletions
synapse/storage/databases/main/state.py
tests/handlers/test_room_summary.py
+4
-1
4 additions, 1 deletion
tests/handlers/test_room_summary.py
with
18 additions
and
15 deletions
changelog.d/11808.misc
0 → 100644
+
1
−
0
View file @
8e56a1b7
Make method `get_room_version` use cached `get_room_version_id`.
This diff is collapsed.
Click to expand it.
synapse/storage/databases/main/state.py
+
13
−
14
View file @
8e56a1b7
...
...
@@ -42,6 +42,16 @@ logger = logging.getLogger(__name__)
MAX_STATE_DELTA_HOPS
=
100
def
_retrieve_and_check_room_version
(
room_id
:
str
,
room_version_id
:
str
)
->
RoomVersion
:
v
=
KNOWN_ROOM_VERSIONS
.
get
(
room_version_id
)
if
not
v
:
raise
UnsupportedRoomVersionError
(
"
Room %s uses a room version %s which is no longer supported
"
%
(
room_id
,
room_version_id
)
)
return
v
# this inherits from EventsWorkerStore because it calls self.get_events
class
StateGroupWorkerStore
(
EventsWorkerStore
,
SQLBaseStore
):
"""
The parts of StateGroupStore that can be called from workers.
"""
...
...
@@ -62,11 +72,8 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
Typically this happens if support for the room
'
s version has been
removed from Synapse.
"""
return
await
self
.
db_pool
.
runInteraction
(
"
get_room_version_txn
"
,
self
.
get_room_version_txn
,
room_id
,
)
room_version_id
=
await
self
.
get_room_version_id
(
room_id
)
return
_retrieve_and_check_room_version
(
room_id
,
room_version_id
)
def
get_room_version_txn
(
self
,
txn
:
LoggingTransaction
,
room_id
:
str
...
...
@@ -82,15 +89,7 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
removed from Synapse.
"""
room_version_id
=
self
.
get_room_version_id_txn
(
txn
,
room_id
)
v
=
KNOWN_ROOM_VERSIONS
.
get
(
room_version_id
)
if
not
v
:
raise
UnsupportedRoomVersionError
(
"
Room %s uses a room version %s which is no longer supported
"
%
(
room_id
,
room_version_id
)
)
return
v
return
_retrieve_and_check_room_version
(
room_id
,
room_version_id
)
@cached
(
max_entries
=
10000
)
async
def
get_room_version_id
(
self
,
room_id
:
str
)
->
str
:
...
...
This diff is collapsed.
Click to expand it.
tests/handlers/test_room_summary.py
+
4
−
1
View file @
8e56a1b7
...
...
@@ -658,7 +658,7 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
def
test_unknown_room_version
(
self
):
"""
If a
n
room with an unknown room version is encountered it should not cause
If a room with an unknown room version is encountered it should not cause
the entire summary to skip.
"""
# Poke the database and update the room version to an unknown one.
...
...
@@ -670,6 +670,9 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
desc
=
"
updated-room-version
"
,
)
)
# Invalidate method so that it returns the currently updated version
# instead of the cached version.
self
.
hs
.
get_datastores
().
main
.
get_room_version_id
.
invalidate
((
self
.
room
,))
# The result should have only the space, along with a link from space -> room.
expected
=
[(
self
.
space
,
[
self
.
room
])]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment