|
| 1 | +--- a/synapse/storage/controllers/state.py 2026-06-16 02:07:49.851487330 +0300 |
| 2 | ++++ b/synapse/storage/controllers/state.py 2026-06-16 02:07:13.674945849 +0300 |
| 3 | +@@ -45,6 +45,7 @@ |
| 4 | + from synapse.util.caches import intern_string |
| 5 | + from synapse.util.caches.descriptors import cached |
| 6 | + from synapse.util.cancellation import cancellable |
| 7 | ++from synapse.util.duration import Duration |
| 8 | + from synapse.util.metrics import Measure |
| 9 | + |
| 10 | + if TYPE_CHECKING: |
| 11 | +@@ -458,14 +459,25 @@ |
| 12 | + ) |
| 13 | + |
| 14 | + else: |
| 15 | +- # no events in this room - so presumably no state |
| 16 | +- state = {} |
| 17 | ++ state = await self.get_current_state_ids( |
| 18 | ++ room_id, |
| 19 | ++ state_filter=state_filter, |
| 20 | ++ await_full_state=await_full_state, |
| 21 | ++ ) |
| 22 | ++ |
| 23 | ++ for _ in range(3): |
| 24 | ++ await self.clock.sleep(Duration(seconds=1.5)) |
| 25 | ++ new_state = await self.get_current_state_ids( |
| 26 | ++ room_id, |
| 27 | ++ state_filter=state_filter, |
| 28 | ++ await_full_state=await_full_state, |
| 29 | ++ ) |
| 30 | ++ if new_state == state: |
| 31 | ++ break |
| 32 | ++ state = new_state |
| 33 | + |
| 34 | +- # (erikj) This should be rarely hit, but we've had some reports that |
| 35 | +- # we get more state down gappy syncs than we should, so let's add |
| 36 | +- # some logging. |
| 37 | + logger.info( |
| 38 | +- "Failed to find any events in room %s at %s", |
| 39 | ++ "Failed to find any events in room %s at %s; falling back to current state", |
| 40 | + room_id, |
| 41 | + stream_position.room_key, |
| 42 | + ) |
0 commit comments