matrix-synapse 1.139.2__cp39-abi3-macosx_11_0_arm64.whl → 1.140.0rc1__cp39-abi3-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of matrix-synapse might be problematic. Click here for more details.
- {matrix_synapse-1.139.2.dist-info → matrix_synapse-1.140.0rc1.dist-info}/METADATA +5 -3
- {matrix_synapse-1.139.2.dist-info → matrix_synapse-1.140.0rc1.dist-info}/RECORD +157 -154
- synapse/_scripts/generate_workers_map.py +6 -1
- synapse/_scripts/synapse_port_db.py +0 -2
- synapse/_scripts/update_synapse_database.py +1 -6
- synapse/api/auth/base.py +1 -3
- synapse/api/auth/mas.py +6 -8
- synapse/api/auth/msc3861_delegated.py +6 -8
- synapse/api/errors.py +3 -0
- synapse/app/_base.py +101 -39
- synapse/app/admin_cmd.py +2 -4
- synapse/app/appservice.py +1 -1
- synapse/app/client_reader.py +1 -1
- synapse/app/event_creator.py +1 -1
- synapse/app/federation_reader.py +1 -1
- synapse/app/federation_sender.py +1 -1
- synapse/app/frontend_proxy.py +1 -1
- synapse/app/generic_worker.py +17 -11
- synapse/app/homeserver.py +85 -47
- synapse/app/media_repository.py +1 -1
- synapse/app/phone_stats_home.py +16 -14
- synapse/app/pusher.py +1 -1
- synapse/app/synchrotron.py +1 -1
- synapse/app/user_dir.py +1 -1
- synapse/appservice/__init__.py +29 -2
- synapse/appservice/scheduler.py +8 -8
- synapse/config/_base.py +32 -14
- synapse/config/_base.pyi +5 -3
- synapse/config/experimental.py +3 -0
- synapse/config/homeserver.py +27 -1
- synapse/config/logger.py +3 -4
- synapse/config/matrixrtc.py +67 -0
- synapse/crypto/keyring.py +18 -4
- synapse/events/auto_accept_invites.py +0 -1
- synapse/federation/federation_client.py +39 -0
- synapse/federation/federation_server.py +1 -1
- synapse/federation/send_queue.py +3 -0
- synapse/federation/sender/__init__.py +24 -8
- synapse/federation/sender/per_destination_queue.py +31 -8
- synapse/federation/sender/transaction_manager.py +12 -0
- synapse/federation/transport/client.py +29 -0
- synapse/handlers/account_validity.py +2 -4
- synapse/handlers/appservice.py +5 -7
- synapse/handlers/deactivate_account.py +2 -3
- synapse/handlers/delayed_events.py +10 -13
- synapse/handlers/device.py +14 -14
- synapse/handlers/e2e_keys.py +4 -3
- synapse/handlers/federation.py +7 -11
- synapse/handlers/federation_event.py +5 -6
- synapse/handlers/message.py +16 -10
- synapse/handlers/pagination.py +3 -7
- synapse/handlers/presence.py +21 -25
- synapse/handlers/profile.py +1 -1
- synapse/handlers/read_marker.py +3 -1
- synapse/handlers/register.py +8 -1
- synapse/handlers/room.py +13 -4
- synapse/handlers/room_member.py +11 -7
- synapse/handlers/room_policy.py +96 -2
- synapse/handlers/sso.py +1 -1
- synapse/handlers/stats.py +5 -3
- synapse/handlers/sync.py +20 -13
- synapse/handlers/typing.py +5 -10
- synapse/handlers/user_directory.py +12 -11
- synapse/handlers/worker_lock.py +19 -15
- synapse/http/client.py +18 -13
- synapse/http/federation/matrix_federation_agent.py +6 -1
- synapse/http/federation/well_known_resolver.py +3 -1
- synapse/http/matrixfederationclient.py +50 -11
- synapse/http/proxy.py +2 -2
- synapse/http/server.py +36 -2
- synapse/http/site.py +109 -17
- synapse/logging/context.py +165 -63
- synapse/logging/opentracing.py +30 -6
- synapse/logging/scopecontextmanager.py +161 -0
- synapse/media/_base.py +2 -1
- synapse/media/media_repository.py +20 -6
- synapse/media/url_previewer.py +5 -6
- synapse/metrics/_gc.py +3 -1
- synapse/metrics/background_process_metrics.py +128 -24
- synapse/metrics/common_usage_metrics.py +3 -5
- synapse/module_api/__init__.py +42 -5
- synapse/notifier.py +10 -3
- synapse/push/emailpusher.py +5 -4
- synapse/push/httppusher.py +6 -6
- synapse/push/pusherpool.py +3 -8
- synapse/replication/http/devices.py +0 -41
- synapse/replication/tcp/client.py +8 -5
- synapse/replication/tcp/handler.py +2 -3
- synapse/replication/tcp/protocol.py +14 -7
- synapse/replication/tcp/redis.py +16 -11
- synapse/replication/tcp/resource.py +5 -4
- synapse/replication/tcp/streams/__init__.py +2 -0
- synapse/res/providers.json +6 -5
- synapse/rest/__init__.py +2 -0
- synapse/rest/admin/__init__.py +4 -0
- synapse/rest/admin/events.py +69 -0
- synapse/rest/admin/media.py +70 -2
- synapse/rest/client/matrixrtc.py +52 -0
- synapse/rest/client/push_rule.py +1 -1
- synapse/rest/client/room.py +2 -3
- synapse/rest/client/sync.py +1 -0
- synapse/rest/client/transactions.py +1 -1
- synapse/server.py +271 -38
- synapse/server_notices/server_notices_manager.py +1 -0
- synapse/state/__init__.py +4 -1
- synapse/storage/_base.py +1 -1
- synapse/storage/background_updates.py +8 -3
- synapse/storage/controllers/persist_events.py +4 -3
- synapse/storage/controllers/purge_events.py +2 -3
- synapse/storage/controllers/state.py +5 -5
- synapse/storage/database.py +12 -7
- synapse/storage/databases/main/__init__.py +7 -2
- synapse/storage/databases/main/cache.py +4 -3
- synapse/storage/databases/main/censor_events.py +1 -1
- synapse/storage/databases/main/client_ips.py +9 -8
- synapse/storage/databases/main/deviceinbox.py +7 -6
- synapse/storage/databases/main/devices.py +4 -4
- synapse/storage/databases/main/end_to_end_keys.py +6 -3
- synapse/storage/databases/main/event_federation.py +7 -6
- synapse/storage/databases/main/event_push_actions.py +13 -13
- synapse/storage/databases/main/events_bg_updates.py +1 -1
- synapse/storage/databases/main/events_worker.py +6 -8
- synapse/storage/databases/main/lock.py +17 -13
- synapse/storage/databases/main/media_repository.py +2 -2
- synapse/storage/databases/main/metrics.py +6 -6
- synapse/storage/databases/main/monthly_active_users.py +3 -4
- synapse/storage/databases/main/receipts.py +1 -1
- synapse/storage/databases/main/registration.py +18 -19
- synapse/storage/databases/main/roommember.py +1 -1
- synapse/storage/databases/main/session.py +3 -3
- synapse/storage/databases/main/sliding_sync.py +2 -2
- synapse/storage/databases/main/transactions.py +3 -3
- synapse/storage/databases/state/store.py +2 -0
- synapse/synapse_rust/http_client.pyi +4 -0
- synapse/synapse_rust.abi3.so +0 -0
- synapse/util/async_helpers.py +36 -24
- synapse/util/batching_queue.py +16 -6
- synapse/util/caches/__init__.py +1 -1
- synapse/util/caches/deferred_cache.py +4 -0
- synapse/util/caches/descriptors.py +14 -2
- synapse/util/caches/dictionary_cache.py +6 -1
- synapse/util/caches/expiringcache.py +16 -5
- synapse/util/caches/lrucache.py +14 -26
- synapse/util/caches/response_cache.py +11 -1
- synapse/util/clock.py +215 -39
- synapse/util/constants.py +2 -0
- synapse/util/daemonize.py +5 -1
- synapse/util/distributor.py +9 -5
- synapse/util/metrics.py +35 -6
- synapse/util/ratelimitutils.py +4 -1
- synapse/util/retryutils.py +7 -4
- synapse/util/task_scheduler.py +11 -14
- synapse/logging/filter.py +0 -38
- {matrix_synapse-1.139.2.dist-info → matrix_synapse-1.140.0rc1.dist-info}/AUTHORS.rst +0 -0
- {matrix_synapse-1.139.2.dist-info → matrix_synapse-1.140.0rc1.dist-info}/LICENSE-AGPL-3.0 +0 -0
- {matrix_synapse-1.139.2.dist-info → matrix_synapse-1.140.0rc1.dist-info}/LICENSE-COMMERCIAL +0 -0
- {matrix_synapse-1.139.2.dist-info → matrix_synapse-1.140.0rc1.dist-info}/WHEEL +0 -0
- {matrix_synapse-1.139.2.dist-info → matrix_synapse-1.140.0rc1.dist-info}/entry_points.txt +0 -0
synapse/util/retryutils.py
CHANGED
|
@@ -24,7 +24,6 @@ from types import TracebackType
|
|
|
24
24
|
from typing import TYPE_CHECKING, Any, Optional, Type
|
|
25
25
|
|
|
26
26
|
from synapse.api.errors import CodeMessageException
|
|
27
|
-
from synapse.metrics.background_process_metrics import run_as_background_process
|
|
28
27
|
from synapse.storage import DataStore
|
|
29
28
|
from synapse.types import StrCollection
|
|
30
29
|
from synapse.util.clock import Clock
|
|
@@ -32,6 +31,7 @@ from synapse.util.clock import Clock
|
|
|
32
31
|
if TYPE_CHECKING:
|
|
33
32
|
from synapse.notifier import Notifier
|
|
34
33
|
from synapse.replication.tcp.handler import ReplicationCommandHandler
|
|
34
|
+
from synapse.server import HomeServer
|
|
35
35
|
|
|
36
36
|
logger = logging.getLogger(__name__)
|
|
37
37
|
|
|
@@ -62,6 +62,7 @@ async def get_retry_limiter(
|
|
|
62
62
|
*,
|
|
63
63
|
destination: str,
|
|
64
64
|
our_server_name: str,
|
|
65
|
+
hs: "HomeServer",
|
|
65
66
|
clock: Clock,
|
|
66
67
|
store: DataStore,
|
|
67
68
|
ignore_backoff: bool = False,
|
|
@@ -124,6 +125,7 @@ async def get_retry_limiter(
|
|
|
124
125
|
return RetryDestinationLimiter(
|
|
125
126
|
destination=destination,
|
|
126
127
|
our_server_name=our_server_name,
|
|
128
|
+
hs=hs,
|
|
127
129
|
clock=clock,
|
|
128
130
|
store=store,
|
|
129
131
|
failure_ts=failure_ts,
|
|
@@ -163,6 +165,7 @@ class RetryDestinationLimiter:
|
|
|
163
165
|
*,
|
|
164
166
|
destination: str,
|
|
165
167
|
our_server_name: str,
|
|
168
|
+
hs: "HomeServer",
|
|
166
169
|
clock: Clock,
|
|
167
170
|
store: DataStore,
|
|
168
171
|
failure_ts: Optional[int],
|
|
@@ -181,6 +184,7 @@ class RetryDestinationLimiter:
|
|
|
181
184
|
Args:
|
|
182
185
|
destination
|
|
183
186
|
our_server_name: Our homeserver name (used to label metrics) (`hs.hostname`)
|
|
187
|
+
hs: The homeserver instance
|
|
184
188
|
clock
|
|
185
189
|
store
|
|
186
190
|
failure_ts: when this destination started failing (in ms since
|
|
@@ -197,6 +201,7 @@ class RetryDestinationLimiter:
|
|
|
197
201
|
error code.
|
|
198
202
|
"""
|
|
199
203
|
self.our_server_name = our_server_name
|
|
204
|
+
self.hs = hs
|
|
200
205
|
self.clock = clock
|
|
201
206
|
self.store = store
|
|
202
207
|
self.destination = destination
|
|
@@ -331,6 +336,4 @@ class RetryDestinationLimiter:
|
|
|
331
336
|
logger.exception("Failed to store destination_retry_timings")
|
|
332
337
|
|
|
333
338
|
# we deliberately do this in the background.
|
|
334
|
-
run_as_background_process(
|
|
335
|
-
"store_retry_timings", self.our_server_name, store_retry_timings
|
|
336
|
-
)
|
|
339
|
+
self.hs.run_as_background_process("store_retry_timings", store_retry_timings)
|
synapse/util/task_scheduler.py
CHANGED
|
@@ -27,12 +27,11 @@ from twisted.python.failure import Failure
|
|
|
27
27
|
from synapse.logging.context import (
|
|
28
28
|
ContextResourceUsage,
|
|
29
29
|
LoggingContext,
|
|
30
|
+
PreserveLoggingContext,
|
|
30
31
|
nested_logging_context,
|
|
31
|
-
set_current_context,
|
|
32
32
|
)
|
|
33
33
|
from synapse.metrics import SERVER_NAME_LABEL, LaterGauge
|
|
34
34
|
from synapse.metrics.background_process_metrics import (
|
|
35
|
-
run_as_background_process,
|
|
36
35
|
wrap_as_background_process,
|
|
37
36
|
)
|
|
38
37
|
from synapse.types import JsonMapping, ScheduledTask, TaskStatus
|
|
@@ -107,10 +106,8 @@ class TaskScheduler:
|
|
|
107
106
|
OCCASIONAL_REPORT_INTERVAL_MS = 5 * 60 * 1000 # 5 minutes
|
|
108
107
|
|
|
109
108
|
def __init__(self, hs: "HomeServer"):
|
|
110
|
-
self.
|
|
111
|
-
self.server_name =
|
|
112
|
-
hs.hostname
|
|
113
|
-
) # nb must be called this for @wrap_as_background_process
|
|
109
|
+
self.hs = hs # nb must be called this for @wrap_as_background_process
|
|
110
|
+
self.server_name = hs.hostname
|
|
114
111
|
self._store = hs.get_datastores().main
|
|
115
112
|
self._clock = hs.get_clock()
|
|
116
113
|
self._running_tasks: Set[str] = set()
|
|
@@ -215,7 +212,7 @@ class TaskScheduler:
|
|
|
215
212
|
if self._run_background_tasks:
|
|
216
213
|
self._launch_scheduled_tasks()
|
|
217
214
|
else:
|
|
218
|
-
self.
|
|
215
|
+
self.hs.get_replication_command_handler().send_new_active_task(task.id)
|
|
219
216
|
|
|
220
217
|
return task.id
|
|
221
218
|
|
|
@@ -362,7 +359,7 @@ class TaskScheduler:
|
|
|
362
359
|
finally:
|
|
363
360
|
self._launching_new_tasks = False
|
|
364
361
|
|
|
365
|
-
run_as_background_process("launch_scheduled_tasks",
|
|
362
|
+
self.hs.run_as_background_process("launch_scheduled_tasks", inner)
|
|
366
363
|
|
|
367
364
|
@wrap_as_background_process("clean_scheduled_tasks")
|
|
368
365
|
async def _clean_scheduled_tasks(self) -> None:
|
|
@@ -425,14 +422,11 @@ class TaskScheduler:
|
|
|
425
422
|
"""
|
|
426
423
|
|
|
427
424
|
current_time = self._clock.time()
|
|
428
|
-
|
|
429
|
-
try:
|
|
425
|
+
with PreserveLoggingContext(task_log_context):
|
|
430
426
|
usage = task_log_context.get_resource_usage()
|
|
431
427
|
TaskScheduler._log_task_usage(
|
|
432
428
|
"continuing", task, usage, current_time - start_time
|
|
433
429
|
)
|
|
434
|
-
finally:
|
|
435
|
-
set_current_context(calling_context)
|
|
436
430
|
|
|
437
431
|
async def wrapper() -> None:
|
|
438
432
|
with nested_logging_context(task.id) as log_context:
|
|
@@ -473,7 +467,10 @@ class TaskScheduler:
|
|
|
473
467
|
occasional_status_call.stop()
|
|
474
468
|
|
|
475
469
|
# Try launch a new task since we've finished with this one.
|
|
476
|
-
self._clock.call_later(
|
|
470
|
+
self._clock.call_later(
|
|
471
|
+
0.1,
|
|
472
|
+
self._launch_scheduled_tasks,
|
|
473
|
+
)
|
|
477
474
|
|
|
478
475
|
if len(self._running_tasks) >= TaskScheduler.MAX_CONCURRENT_RUNNING_TASKS:
|
|
479
476
|
return
|
|
@@ -493,4 +490,4 @@ class TaskScheduler:
|
|
|
493
490
|
|
|
494
491
|
self._running_tasks.add(task.id)
|
|
495
492
|
await self.update_task(task.id, status=TaskStatus.ACTIVE)
|
|
496
|
-
run_as_background_process(f"task-{task.action}",
|
|
493
|
+
self.hs.run_as_background_process(f"task-{task.action}", wrapper)
|
synapse/logging/filter.py
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# This file is licensed under the Affero General Public License (AGPL) version 3.
|
|
3
|
-
#
|
|
4
|
-
# Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
5
|
-
# Copyright (C) 2023 New Vector, Ltd
|
|
6
|
-
#
|
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU Affero General Public License as
|
|
9
|
-
# published by the Free Software Foundation, either version 3 of the
|
|
10
|
-
# License, or (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# See the GNU Affero General Public License for more details:
|
|
13
|
-
# <https://www.gnu.org/licenses/agpl-3.0.html>.
|
|
14
|
-
#
|
|
15
|
-
# Originally licensed under the Apache License, Version 2.0:
|
|
16
|
-
# <http://www.apache.org/licenses/LICENSE-2.0>.
|
|
17
|
-
#
|
|
18
|
-
# [This file includes modifications made by New Vector Limited]
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
import logging
|
|
22
|
-
from typing import Literal
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class MetadataFilter(logging.Filter):
|
|
26
|
-
"""Logging filter that adds constant values to each record.
|
|
27
|
-
|
|
28
|
-
Args:
|
|
29
|
-
metadata: Key-value pairs to add to each record.
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
def __init__(self, metadata: dict):
|
|
33
|
-
self._metadata = metadata
|
|
34
|
-
|
|
35
|
-
def filter(self, record: logging.LogRecord) -> Literal[True]:
|
|
36
|
-
for key, value in self._metadata.items():
|
|
37
|
-
setattr(record, key, value)
|
|
38
|
-
return True
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|