Repository: matrix-org/synapse

Issue:
Synapse 1.7.1 has many Failed to backfill from X because _get_state_for_room() missing 1 required positional argument: 'include_event_in_state'
### Description

My Synapse 1.7.1 logs are full of the following errors:

```
Failed to backfill from X because _get_state_for_room() missing 1 required positional argument: 'include_event_in_state'
Dec 19 17:10:21 bubu synapse[26632]: TypeError: _get_state_for_room() missing 1 required positional argument: 'include_event_in_state'
Dec 19 17:10:21 bubu synapse[26632]:     return f(*args, **kwargs)
Dec 19 17:10:21 bubu synapse[26632]:   File "/usr/lib/python3.8/site-packages/synapse/logging/utils.py", line 79, in wrapped
Dec 19 17:10:21 bubu synapse[26632]:     gen = f(*args, **kwargs)
Dec 19 17:10:21 bubu synapse[26632]:   File "/usr/lib/python3.8/site-packages/twisted/internet/defer.py", line 1604, in unwindGenerator
Dec 19 17:10:21 bubu synapse[26632]:     state, auth = yield self._get_state_for_room(
Dec 19 17:10:21 bubu synapse[26632]:   File "/usr/lib/python3.8/site-packages/synapse/handlers/federation.py", line 799, in backfill
Dec 19 17:10:21 bubu synapse[26632]:     result = g.send(result)
Dec 19 17:10:21 bubu synapse[26632]:   File "/usr/lib/python3.8/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
Dec 19 17:10:21 bubu synapse[26632]:     yield self.backfill(
Dec 19 17:10:21 bubu synapse[26632]:   File "/usr/lib/python3.8/site-packages/synapse/handlers/federation.py", line 982, in try_backfill
Dec 19 17:10:21 bubu synapse[26632]: Traceback (most recent call last):
Dec 19 17:10:21 bubu synapse[26632]: During handling of the above exception, another exception occurred:
Dec 19 17:10:21 bubu synapse[26632]: StopIteration: set()
Dec 19 17:10:21 bubu synapse[26632]:     result = g.send(result)
Dec 19 17:10:21 bubu synapse[26632]:   File "/usr/lib/python3.8/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
Dec 19 17:10:21 bubu synapse[26632]: Traceback (most recent call last):
Dec 19 17:10:21 bubu synapse[26632]: During handling of the above exception, another exception occurred:
Dec 19 17:10:21 bubu synapse[26632]: StopIteration: []
Dec 19 17:10:21 bubu synapse[26632]:     result = g.send(result)
Dec 19 17:10:21 bubu synapse[26632]:   File "/usr/lib/python3.8/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
Dec 19 17:10:21 bubu synapse[26632]: Traceback (most recent call last):
Dec 19 17:10:21 bubu synapse[26632]: During handling of the above exception, another exception occurred:
Dec 19 17:10:21 bubu synapse[26632]: StopIteration: []
Dec 19 17:10:21 bubu synapse[26632]:     result = g.send(result)
Dec 19 17:10:21 bubu synapse[26632]:   File "/usr/lib/python3.8/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
Dec 19 17:10:21 bubu synapse[26632]: Traceback (most recent call last):
Dec 19 17:10:21 bubu synapse[26632]: During handling of the above exception, another exception occurred:
Dec 19 17:10:21 bubu synapse[26632]: StopIteration: []
Dec 19 17:10:21 bubu synapse[26632]:     result = g.send(result)
Dec 19 17:10:21 bubu synapse[26632]:   File "/usr/lib/python3.8/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
Dec 19 17:10:21 bubu synapse[26632]: Traceback (most recent call last):
```

### Version information

<!-- IMPORTANT: please answer the following questions, to help us narrow down the problem -->

<!-- Was this issue identified on matrix.org or another homeserver? -->
- **Homeserver**: bubu1.eu
- **Version**: 1.7.1

- **Install method**:
archlinux package

- **Platform**:
archlinux


Discussion:
@richvdh FYI

Resolving patch:
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -797,7 +797,10 @@ def backfill(self, dest, room_id, limit, extremities):
         events_to_state = {}
         for e_id in edges:
             state, auth = yield self._get_state_for_room(
-                destination=dest, room_id=room_id, event_id=e_id
+                destination=dest,
+                room_id=room_id,
+                event_id=e_id,
+                include_event_in_state=False,
             )
             auth_events.update({a.event_id: a for a in auth})
             auth_events.update({s.event_id: s for s in state})


Test patch: