summary refs log tree commit diff
path: root/synapse/storage/controllers
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2023-05-23 12:26:25 -0500
committerGitHub <noreply@github.com>2023-05-23 12:26:25 -0500
commit379eb2d7abc8e3215cc9fd14deefb975137c9494 (patch)
tree1aa94d1c9f38e37fba464fd48e1e2db172c648a0 /synapse/storage/controllers
parentConsolidate logic to check for deactivated users. (#15634) (diff)
downloadsynapse-379eb2d7abc8e3215cc9fd14deefb975137c9494.tar.xz
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 https://github.com/matrix-org/synapse/pull/15610

Diffstat (limited to 'synapse/storage/controllers')
-rw-r--r--synapse/storage/controllers/state.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/synapse/storage/controllers/state.py b/synapse/storage/controllers/state.py
index 06a80869eb..7089b0a1d8 100644
--- a/synapse/storage/controllers/state.py
+++ b/synapse/storage/controllers/state.py
@@ -16,7 +16,6 @@ from typing import (
     TYPE_CHECKING,
     AbstractSet,
     Any,
-    Awaitable,
     Callable,
     Collection,
     Dict,
@@ -175,9 +174,9 @@ class StateStorageController:
 
     @trace
     @tag_args
-    def _get_state_groups_from_groups(
+    async def _get_state_groups_from_groups(
         self, groups: List[int], state_filter: StateFilter
-    ) -> Awaitable[Dict[int, StateMap[str]]]:
+    ) -> Dict[int, StateMap[str]]:
         """Returns the state groups for a given set of groups, filtering on
         types of state events.
 
@@ -190,7 +189,9 @@ class StateStorageController:
             Dict of state group to state map.
         """
 
-        return self.stores.state._get_state_groups_from_groups(groups, state_filter)
+        return await self.stores.state._get_state_groups_from_groups(
+            groups, state_filter
+        )
 
     @trace
     @tag_args
@@ -349,9 +350,9 @@ class StateStorageController:
 
     @trace
     @tag_args
-    def get_state_for_groups(
+    async def get_state_for_groups(
         self, groups: Iterable[int], state_filter: Optional[StateFilter] = None
-    ) -> Awaitable[Dict[int, MutableStateMap[str]]]:
+    ) -> Dict[int, MutableStateMap[str]]:
         """Gets the state at each of a list of state groups, optionally
         filtering by type/state_key
 
@@ -363,7 +364,7 @@ class StateStorageController:
         Returns:
             Dict of state group to state map.
         """
-        return self.stores.state._get_state_for_groups(
+        return await self.stores.state._get_state_for_groups(
             groups, state_filter or StateFilter.all()
         )