-
Notifications
You must be signed in to change notification settings - Fork 404
Move unique snowflake homeserver background tasks to start_background_tasks
#19037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
19d58cb
c75ef69
ad66d45
2a57bb6
139f6e8
5917d8e
141ca5d
fd2c661
d34622b
fd5ffd5
c6a4286
9087b2e
608e917
43361a9
8f784b0
6465998
d8557ae
7b0a738
a000838
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Move unique snowflake homeserver background tasks to `start_background_tasks` (the standard pattern for this kind of thing). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ | |
| from synapse.api.filtering import Filtering | ||
| from synapse.api.ratelimiting import Ratelimiter, RequestRatelimiter | ||
| from synapse.app._base import unregister_sighups | ||
| from synapse.app.phone_stats_home import start_phone_stats_home | ||
| from synapse.appservice.api import ApplicationServiceApi | ||
| from synapse.appservice.scheduler import ApplicationServiceScheduler | ||
| from synapse.config.homeserver import HomeServerConfig | ||
|
|
@@ -643,6 +644,8 @@ def start_background_tasks(self) -> None: | |
| for i in self.REQUIRED_ON_BACKGROUND_TASK_STARTUP: | ||
| getattr(self, "get_" + i + "_handler")() | ||
| self.get_task_scheduler() | ||
| self.get_common_usage_metrics_manager().setup() | ||
| start_phone_stats_home(self) | ||
|
Comment on lines
+647
to
+648
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to |
||
|
|
||
| def get_reactor(self) -> ISynapseReactor: | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -46,28 +46,39 @@ def test_update_function_room_account_data_limit(self) -> None: | |||||||||||
|
|
||||||||||||
| # check we're testing what we think we are: no rows should yet have been | ||||||||||||
| # received | ||||||||||||
| self.assertEqual([], self.test_handler.received_rdata_rows) | ||||||||||||
| received_account_data_rows = [ | ||||||||||||
| row | ||||||||||||
| for row in self.test_handler.received_rdata_rows | ||||||||||||
| if row[0] == AccountDataStream.NAME | ||||||||||||
| ] | ||||||||||||
| self.assertEqual([], received_account_data_rows) | ||||||||||||
|
Comment on lines
+49
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to filter the synapse/tests/replication/tcp/streams/test_thread_subscriptions.py Lines 91 to 95 in d399d76
Not all of these tests were failing but some tests were failing because we had some While we don't care about phone home stats in tests, it's at-least a good sign that our homeserver is more closely running to how it would in the real-life case. |
||||||||||||
|
|
||||||||||||
| # now reconnect to pull the updates | ||||||||||||
| self.reconnect() | ||||||||||||
| self.replicate() | ||||||||||||
|
|
||||||||||||
| # we should have received all the expected rows in the right order | ||||||||||||
| received_rows = self.test_handler.received_rdata_rows | ||||||||||||
| # We should have received all the expected rows in the right order | ||||||||||||
| # | ||||||||||||
| # Filter the updates to only include account data changes | ||||||||||||
| received_account_data_rows = [ | ||||||||||||
| row | ||||||||||||
| for row in self.test_handler.received_rdata_rows | ||||||||||||
| if row[0] == AccountDataStream.NAME | ||||||||||||
| ] | ||||||||||||
|
|
||||||||||||
| for t in updates: | ||||||||||||
| (stream_name, token, row) = received_rows.pop(0) | ||||||||||||
| (stream_name, token, row) = received_account_data_rows.pop(0) | ||||||||||||
| self.assertEqual(stream_name, AccountDataStream.NAME) | ||||||||||||
| self.assertIsInstance(row, AccountDataStream.AccountDataStreamRow) | ||||||||||||
| self.assertEqual(row.data_type, t) | ||||||||||||
| self.assertEqual(row.room_id, "test_room") | ||||||||||||
|
|
||||||||||||
| (stream_name, token, row) = received_rows.pop(0) | ||||||||||||
| (stream_name, token, row) = received_account_data_rows.pop(0) | ||||||||||||
| self.assertIsInstance(row, AccountDataStream.AccountDataStreamRow) | ||||||||||||
| self.assertEqual(row.data_type, "m.global") | ||||||||||||
| self.assertIsNone(row.room_id) | ||||||||||||
|
|
||||||||||||
| self.assertEqual([], received_rows) | ||||||||||||
| self.assertEqual([], received_account_data_rows) | ||||||||||||
|
|
||||||||||||
| def test_update_function_global_account_data_limit(self) -> None: | ||||||||||||
| """Test replication with many global account data updates""" | ||||||||||||
|
|
@@ -85,32 +96,38 @@ def test_update_function_global_account_data_limit(self) -> None: | |||||||||||
| store.add_account_data_to_room("test_user", "test_room", "m.per_room", {}) | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| # tell the notifier to catch up to avoid duplicate rows. | ||||||||||||
| # workaround for https://github.com/matrix-org/synapse/issues/7360 | ||||||||||||
| # FIXME remove this when the above is fixed | ||||||||||||
| self.replicate() | ||||||||||||
|
|
||||||||||||
| # check we're testing what we think we are: no rows should yet have been | ||||||||||||
| # received | ||||||||||||
| self.assertEqual([], self.test_handler.received_rdata_rows) | ||||||||||||
| received_account_data_rows = [ | ||||||||||||
| row | ||||||||||||
| for row in self.test_handler.received_rdata_rows | ||||||||||||
| if row[0] == AccountDataStream.NAME | ||||||||||||
| ] | ||||||||||||
| self.assertEqual([], received_account_data_rows) | ||||||||||||
|
|
||||||||||||
| # now reconnect to pull the updates | ||||||||||||
| self.reconnect() | ||||||||||||
| self.replicate() | ||||||||||||
|
|
||||||||||||
| # we should have received all the expected rows in the right order | ||||||||||||
| received_rows = self.test_handler.received_rdata_rows | ||||||||||||
| # | ||||||||||||
| # Filter the updates to only include typing changes | ||||||||||||
| received_account_data_rows = [ | ||||||||||||
| row | ||||||||||||
| for row in self.test_handler.received_rdata_rows | ||||||||||||
| if row[0] == AccountDataStream.NAME | ||||||||||||
| ] | ||||||||||||
|
|
||||||||||||
| for t in updates: | ||||||||||||
| (stream_name, token, row) = received_rows.pop(0) | ||||||||||||
| (stream_name, token, row) = received_account_data_rows.pop(0) | ||||||||||||
| self.assertEqual(stream_name, AccountDataStream.NAME) | ||||||||||||
| self.assertIsInstance(row, AccountDataStream.AccountDataStreamRow) | ||||||||||||
| self.assertEqual(row.data_type, t) | ||||||||||||
| self.assertIsNone(row.room_id) | ||||||||||||
|
|
||||||||||||
| (stream_name, token, row) = received_rows.pop(0) | ||||||||||||
| (stream_name, token, row) = received_account_data_rows.pop(0) | ||||||||||||
| self.assertIsInstance(row, AccountDataStream.AccountDataStreamRow) | ||||||||||||
| self.assertEqual(row.data_type, "m.per_room") | ||||||||||||
| self.assertEqual(row.room_id, "test_room") | ||||||||||||
|
|
||||||||||||
| self.assertEqual([], received_rows) | ||||||||||||
| self.assertEqual([], received_account_data_rows) | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
asyncas nothing was usingawaithere and fits the pattern better forstart_background_tasks