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

Commit 379eb2d

Browse files
Fix @trace not wrapping some state methods that return coroutines correctly (#15647)
``` 2023-05-21 09:30:09,288 - synapse.logging.opentracing - 940 - ERROR - POST-1 - @trace may not have wrapped StateStorageController.get_state_for_groups correctly! The function is not async but returned a coroutine ``` Tracing instrumentation for these functions originally introduced in #15610
1 parent 7c9b917 commit 379eb2d

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

changelog.d/15647.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Instrument `state` and `state_group` storage-related operations to better picture what's happening when tracing.

synapse/storage/controllers/state.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
TYPE_CHECKING,
1717
AbstractSet,
1818
Any,
19-
Awaitable,
2019
Callable,
2120
Collection,
2221
Dict,
@@ -175,9 +174,9 @@ async def get_state_groups(
175174

176175
@trace
177176
@tag_args
178-
def _get_state_groups_from_groups(
177+
async def _get_state_groups_from_groups(
179178
self, groups: List[int], state_filter: StateFilter
180-
) -> Awaitable[Dict[int, StateMap[str]]]:
179+
) -> Dict[int, StateMap[str]]:
181180
"""Returns the state groups for a given set of groups, filtering on
182181
types of state events.
183182
@@ -190,7 +189,9 @@ def _get_state_groups_from_groups(
190189
Dict of state group to state map.
191190
"""
192191

193-
return self.stores.state._get_state_groups_from_groups(groups, state_filter)
192+
return await self.stores.state._get_state_groups_from_groups(
193+
groups, state_filter
194+
)
194195

195196
@trace
196197
@tag_args
@@ -349,9 +350,9 @@ async def get_state_ids_for_event(
349350

350351
@trace
351352
@tag_args
352-
def get_state_for_groups(
353+
async def get_state_for_groups(
353354
self, groups: Iterable[int], state_filter: Optional[StateFilter] = None
354-
) -> Awaitable[Dict[int, MutableStateMap[str]]]:
355+
) -> Dict[int, MutableStateMap[str]]:
355356
"""Gets the state at each of a list of state groups, optionally
356357
filtering by type/state_key
357358
@@ -363,7 +364,7 @@ def get_state_for_groups(
363364
Returns:
364365
Dict of state group to state map.
365366
"""
366-
return self.stores.state._get_state_for_groups(
367+
return await self.stores.state._get_state_for_groups(
367368
groups, state_filter or StateFilter.all()
368369
)
369370

0 commit comments

Comments
 (0)