summary refs log tree commit diff
path: root/synapse/state/__init__.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-01-26 13:57:31 +0000
committerGitHub <noreply@github.com>2021-01-26 13:57:31 +0000
commitdd8da8c5f6ac525a7456437913a03f68d4504605 (patch)
treebdb8f0272ab4a4034091c9bd428ed7390bbb92d8 /synapse/state/__init__.py
parentTry to recover from unknown encodings when previewing media. (#9164) (diff)
downloadsynapse-dd8da8c5f6ac525a7456437913a03f68d4504605.tar.xz
Precompute joined hosts and store in Redis (#9198)
Diffstat (limited to 'synapse/state/__init__.py')
-rw-r--r--synapse/state/__init__.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/synapse/state/__init__.py b/synapse/state/__init__.py
index 84f59c7d85..3bd9ff8ca0 100644
--- a/synapse/state/__init__.py
+++ b/synapse/state/__init__.py
@@ -310,6 +310,7 @@ class StateHandler:
             state_group_before_event = None
             state_group_before_event_prev_group = None
             deltas_to_state_group_before_event = None
+            entry = None
 
         else:
             # otherwise, we'll need to resolve the state across the prev_events.
@@ -340,9 +341,13 @@ class StateHandler:
                 current_state_ids=state_ids_before_event,
             )
 
-            # XXX: can we update the state cache entry for the new state group? or
-            # could we set a flag on resolve_state_groups_for_events to tell it to
-            # always make a state group?
+            # Assign the new state group to the cached state entry.
+            #
+            # Note that this can race in that we could generate multiple state
+            # groups for the same state entry, but that is just inefficient
+            # rather than dangerous.
+            if entry and entry.state_group is None:
+                entry.state_group = state_group_before_event
 
         #
         # now if it's not a state event, we're done