mirror of
https://github.com/element-hq/synapse
synced 2024-08-18 23:50:52 +00:00
Merge pull request #2631 from xyzz/fix_appservice_event_backlog
Fix appservices being backlogged and not receiving new events due to a bug in notify_interested_services
This commit is contained in:
commit
d305987b40
2 changed files with 13 additions and 8 deletions
|
@ -70,11 +70,10 @@ class ApplicationServicesHandler(object):
|
||||||
with Measure(self.clock, "notify_interested_services"):
|
with Measure(self.clock, "notify_interested_services"):
|
||||||
self.is_processing = True
|
self.is_processing = True
|
||||||
try:
|
try:
|
||||||
upper_bound = self.current_max
|
|
||||||
limit = 100
|
limit = 100
|
||||||
while True:
|
while True:
|
||||||
upper_bound, events = yield self.store.get_new_events_for_appservice(
|
upper_bound, events = yield self.store.get_new_events_for_appservice(
|
||||||
upper_bound, limit
|
self.current_max, limit
|
||||||
)
|
)
|
||||||
|
|
||||||
if not events:
|
if not events:
|
||||||
|
@ -105,9 +104,6 @@ class ApplicationServicesHandler(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
yield self.store.set_appservice_last_pos(upper_bound)
|
yield self.store.set_appservice_last_pos(upper_bound)
|
||||||
|
|
||||||
if len(events) < limit:
|
|
||||||
break
|
|
||||||
finally:
|
finally:
|
||||||
self.is_processing = False
|
self.is_processing = False
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,10 @@ class AppServiceHandlerTestCase(unittest.TestCase):
|
||||||
type="m.room.message",
|
type="m.room.message",
|
||||||
room_id="!foo:bar"
|
room_id="!foo:bar"
|
||||||
)
|
)
|
||||||
self.mock_store.get_new_events_for_appservice.return_value = (0, [event])
|
self.mock_store.get_new_events_for_appservice.side_effect = [
|
||||||
|
(0, [event]),
|
||||||
|
(0, [])
|
||||||
|
]
|
||||||
self.mock_as_api.push = Mock()
|
self.mock_as_api.push = Mock()
|
||||||
yield self.handler.notify_interested_services(0)
|
yield self.handler.notify_interested_services(0)
|
||||||
self.mock_scheduler.submit_event_for_as.assert_called_once_with(
|
self.mock_scheduler.submit_event_for_as.assert_called_once_with(
|
||||||
|
@ -75,7 +78,10 @@ class AppServiceHandlerTestCase(unittest.TestCase):
|
||||||
)
|
)
|
||||||
self.mock_as_api.push = Mock()
|
self.mock_as_api.push = Mock()
|
||||||
self.mock_as_api.query_user = Mock()
|
self.mock_as_api.query_user = Mock()
|
||||||
self.mock_store.get_new_events_for_appservice.return_value = (0, [event])
|
self.mock_store.get_new_events_for_appservice.side_effect = [
|
||||||
|
(0, [event]),
|
||||||
|
(0, [])
|
||||||
|
]
|
||||||
yield self.handler.notify_interested_services(0)
|
yield self.handler.notify_interested_services(0)
|
||||||
self.mock_as_api.query_user.assert_called_once_with(
|
self.mock_as_api.query_user.assert_called_once_with(
|
||||||
services[0], user_id
|
services[0], user_id
|
||||||
|
@ -98,7 +104,10 @@ class AppServiceHandlerTestCase(unittest.TestCase):
|
||||||
)
|
)
|
||||||
self.mock_as_api.push = Mock()
|
self.mock_as_api.push = Mock()
|
||||||
self.mock_as_api.query_user = Mock()
|
self.mock_as_api.query_user = Mock()
|
||||||
self.mock_store.get_new_events_for_appservice.return_value = (0, [event])
|
self.mock_store.get_new_events_for_appservice.side_effect = [
|
||||||
|
(0, [event]),
|
||||||
|
(0, [])
|
||||||
|
]
|
||||||
yield self.handler.notify_interested_services(0)
|
yield self.handler.notify_interested_services(0)
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
self.mock_as_api.query_user.called,
|
self.mock_as_api.query_user.called,
|
||||||
|
|
Loading…
Reference in a new issue