summary refs log tree commit diff
path: root/synapse (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Allow health listener resource to load (#15096)realtyem2023-02-201-0/+1
| | | | | | | * Allow health listener resource to load. * changelog * Update changelog.d/15096.bugfix
* Fix a bug introduced in Synapse v1.74.0 where searching with colons when ↵reivilibre2023-02-201-4/+20
| | | | | | using ICU for search term tokenisation would fail with an error. (#15079) Co-authored-by: David Robertson <davidr@element.io>
* Add account data to export command (#14969)Dirk Klimpel2023-02-172-16/+48
| | | | | | | | | | | * Add account data to to export command * newsfile * remove not needed function * update newsfile * adopt #14973
* Mitigate a race where /make_join could 403 for restricted rooms (#15080)Sean Quah2023-02-171-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, when creating a join event in /make_join, we would decide whether to include additional fields to satisfy restricted room checks based on the current state of the room. Then, when building the event, we would capture the forward extremities of the room to use as prev events. This is subject to race conditions. For example, when leaving and rejoining a room, the following sequence of events leads to a misleading 403 response: 1. /make_join reads the current state of the room and sees that the user is still in the room. It decides to omit the field required for restricted room joins. 2. The leave event is persisted and the room's forward extremities are updated. 3. /make_join builds the event, using the post-leave forward extremities. The event then fails the restricted room checks. To mitigate the race, we move the read of the forward extremities closer to the read of the current state. Ideally, we would compute the state based off the chosen prev events, but that can involve state resolution, which is expensive. Signed-off-by: Sean Quah <seanq@matrix.org>
* Use mypy 1.0 (#15052)David Robertson2023-02-168-33/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Update mypy and mypy-zope * Remove unused ignores These used to suppress ``` synapse/storage/engines/__init__.py:28: error: "__new__" must return a class instance (got "NoReturn") [misc] ``` and ``` synapse/http/matrixfederationclient.py:1270: error: "BaseException" has no attribute "reasons" [attr-defined] ``` (note that we check `hasattr(e, "reasons")` above) * Avoid empty body warnings, sometimes by marking methods as abstract E.g. ``` tests/handlers/test_register.py:58: error: Missing return statement [empty-body] tests/handlers/test_register.py:108: error: Missing return statement [empty-body] ``` * Suppress false positive about `JaegerConfig` Complaint was ``` synapse/logging/opentracing.py:450: error: Function "Type[Config]" could always be true in boolean context [truthy-function] ``` * Fix not calling `is_state()` Oops! ``` tests/rest/client/test_third_party_rules.py:428: error: Function "Callable[[], bool]" could always be true in boolean context [truthy-function] ``` * Suppress false positives from ParamSpecs ```` synapse/logging/opentracing.py:971: error: Argument 2 to "_custom_sync_async_decorator" has incompatible type "Callable[[Arg(Callable[P, R], 'func'), **P], _GeneratorContextManager[None]]"; expected "Callable[[Callable[P, R], **P], _GeneratorContextManager[None]]" [arg-type] synapse/logging/opentracing.py:1017: error: Argument 2 to "_custom_sync_async_decorator" has incompatible type "Callable[[Arg(Callable[P, R], 'func'), **P], _GeneratorContextManager[None]]"; expected "Callable[[Callable[P, R], **P], _GeneratorContextManager[None]]" [arg-type] ```` * Drive-by improvement to `wrapping_logic` annotation * Workaround false "unreachable" positives See https://github.com/Shoobx/mypy-zope/issues/91 ``` tests/http/test_proxyagent.py:626: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:762: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:826: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:838: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:845: error: Statement is unreachable [unreachable] tests/http/federation/test_matrix_federation_agent.py:151: error: Statement is unreachable [unreachable] tests/http/federation/test_matrix_federation_agent.py:452: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:60: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:93: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:127: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:152: error: Statement is unreachable [unreachable] ``` * Changelog * Tweak DBAPI2 Protocol to be accepted by mypy 1.0 Some extra context in: - https://github.com/matrix-org/python-canonicaljson/pull/57 - https://github.com/python/mypy/issues/6002 - https://mypy.readthedocs.io/en/latest/common_issues.html#covariant-subtyping-of-mutable-protocol-members-is-rejected * Pull in updated canonicaljson lib so the protocol check just works * Improve comments in opentracing I tried to workaround the ignores but found it too much trouble. I think the corresponding issue is https://github.com/python/mypy/issues/12909. The mypy repo has a PR claiming to fix this (https://github.com/python/mypy/pull/14677) which might mean this gets resolved soon? * Better annotation for INTERACTIVE_AUTH_CHECKERS * Drive-by AUTH_TYPE annotation, to remove an ignore
* Update intentional mentions (MSC3952) to depend on `exact_event_match` ↵Patrick Cloke2023-02-162-7/+4
| | | | | | | | | | (MSC3758). (#15037) This replaces the specific `is_room_mention` push rule condition used in MSC3952 with the generic `exact_event_match` push rule condition from MSC3758. No functionality changes due to this.
* Fix federated joins when the first server in the list is not in the room ↵Sean Quah2023-02-151-6/+5
| | | | | | | | (#15074) Previously we would give up upon receiving a 404 from the first server, instead of trying the rest of the servers in the list. Signed-off-by: Sean Quah <seanq@matrix.org>
* Support for selecting the Redis logical database. (#15034)999lakhisidhu2023-02-152-0/+2
| | | | Note that this is only used for key-value store (cached values) and not for the pub/sub replication used by Synapse.
* Update the error code for duplicate annotation (#15075)Richard van der Hoff2023-02-152-1/+9
|
* Fix order of partial state tables when purging (#15068)David Robertson2023-02-142-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix order of partial state tables when purging `partial_state_rooms` has an FK on `events` pointing to the join event we get from `/send_join`, so we must delete from that table before deleting from `events`. **NB:** It would be nice to cancel any resync processes for the room being purged. We do not do this at present. To do so reliably we'd need an internal HTTP "replication" endpoint, because the worker doing the resync process may be different to that handling the purge request. The first time the resync process tries to write data after the deletion it will fail because we have deleted necessary data e.g. auth events. AFAICS it will not retry the resync, so the only downside to not cancelling the resync is a scary-looking traceback. (This is presumably extremely race-sensitive.) * Changelog * admist(?) -> between * Warn about a race * Fix typo, thanks Sean Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> --------- Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Implement MSC3966: Add a push rule condition to search for a value in an ↵Patrick Cloke2023-02-143-7/+20
| | | | | | array. (#15045) The `exact_event_property_contains` condition can be used to search for a value inside of an array.
* Prevent clients from reporting nonexistent events. (#13779)reivilibre2023-02-141-1/+10
|
* Faster joins: Omit device list updates from partial state rooms in /sync ↵Sean Quah2023-02-141-0/+5
| | | | | | | | | | | | (#15069) ...when lazy loading of members is not enabled. It's weird to notify a client that another user's device list has changed when the client doesn't think that they share a room. Note that when a room is un-partial stated, device list updates are emitted for every member in that room over /sync. Signed-off-by: Sean Quah <seanq@matrix.org>
* Fix clashing DB txn name (#15070)Erik Johnston2023-02-141-1/+1
| | | | | * Fix clashing DB txn name * Newsfile
* Skip calculating unread push actions in `/sync` when `enable_push` is false. ↵Erik Johnston2023-02-142-0/+15
| | | | (#14980)
* Change collection[str] to StrCollection in event_auth code (#14929)Harishankar Kumar2023-02-144-24/+18
| | | Signed-off-by: Harishankar Kumar <hari01584@gmail.com>
* Tweak comment on `_is_local_room_accessible` as part of room visibility in ↵reivilibre2023-02-131-2/+2
| | | | `/hierarchy` to clarify the condition for a room being visible. (#14834)
* Refactor arguments of `try_unbind_threepid(_with_id_server)` from dict to ↵Andrew Morgan2023-02-134-39/+27
| | | | separate args (#15053)
* Apply logging from hotfixes branch to develop (#15054)David Robertson2023-02-131-0/+3
| | | | | | | | | * Apply logging from hotfixes branch to develop Part of #4826. Originally added in #11882. * Changelog
* Faster joins: don't stall when a user joins during a fast join (#14606)Mathieu Velten2023-02-1010-74/+175
| | | | | | | | | | | | | | | | Fixes #12801. Complement tests are at https://github.com/matrix-org/complement/pull/567. Avoid blocking on full state when handling a subsequent join into a partial state room. Also always perform a remote join into partial state rooms, since we do not know whether the joining user has been banned and want to avoid leaking history to banned users. Signed-off-by: Mathieu Velten <mathieuv@matrix.org> Co-authored-by: Sean Quah <seanq@matrix.org> Co-authored-by: David Robertson <davidr@element.io>
* Return read-only collections from `@cached` methods (#13755)Sean Quah2023-02-1025-75/+95
| | | | | | | | | | | | | It's important that collections returned from `@cached` methods are not modified, otherwise future retrievals from the cache will return the modified collection. This applies to the return values from `@cached` methods and the values inside the dictionaries returned by `@cachedList` methods. It's not necessary for the dictionaries returned by `@cachedList` methods themselves to be read-only. Signed-off-by: Sean Quah <seanq@matrix.org> Co-authored-by: David Robertson <davidr@element.io>
* Support for MSC3758: exact_event_match push condition (#14964)Patrick Cloke2023-02-103-7/+18
| | | | | This specifies to search for an exact value match, instead of string globbing. It only works across non-compound JSON values (null, boolean, integer, and strings).
* Avoid fetching unused account data in sync. (#14973)Patrick Cloke2023-02-107-90/+175
| | | | | | | The per-room account data is no longer unconditionally fetched, even if all rooms will be filtered out. Global account data will not be fetched if it will all be filtered out.
* Merge branch 'release-v1.77' into developDavid Robertson2023-02-102-2/+9
|\
| * Bump schema version (#15036)David Robertson2023-02-091-2/+7
| | | | | | | | | | | | | | | | * Bump schema version This should have been included in f10caa73eee0caa91cf373966104d1ededae2aee (and #14979). * Changelog
| * Fix bug in replication where response is cached (#15024)Erik Johnston2023-02-081-0/+2
| |
* | Avoid mutating cached values in `_generate_sync_entry_for_account_data` (#15047)Sean Quah2023-02-101-0/+2
| |
* | Refactor get_user_devices_from_cache to avoid mutating cached values. (#15040)Patrick Cloke2023-02-102-18/+24
| | | | | | | | | | | | | | | | The previous version of the code could mutate a cached value, but only if the input requested all devices of a user *and* a specific device. To avoid this nonsensical situation we no longer fetch a specific device ID if all of a user's devices are returned.
* | Fix exception on start up about device lists (#15041)Erik Johnston2023-02-101-0/+1
| | | | | | Fixes #15010.
* | Tag federation request spans with the worker name (#15042)David Robertson2023-02-092-8/+9
| | | | | | | | | | | | | | * Systematically include worker name as process info * Changelog * don't bother with inner setdefault
* | Add a class UnpersistedEventContext to allow for the batching up of storing ↵Shay2023-02-096-148/+315
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | state groups (#14675) * add class UnpersistedEventContext * modify create new client event to create unpersistedeventcontexts * persist event contexts after creation * fix tests to persist unpersisted event contexts * cleanup * misc lints + cleanup * changelog + fix comments * lints * fix batch insertion? * reduce redundant calculation * add unpersisted event classes * rework compute_event_context, split into function that returns unpersisted event context and then persists it * use calculate_context_info to create unpersisted event contexts * update typing * $%#^&* * black * fix comments and consolidate classes, use attr.s for class * requested changes * lint * requested changes * requested changes * refactor to be stupidly explicit * clearer renaming and flow * make partial state non-optional * update docstrings --------- Co-authored-by: Erik Johnston <erik@matrix.org>
* | Do not always start a db txn on Postgres (#14840)Andrew Morgan2023-02-091-4/+9
| |
* | Respond correctly to unknown methods on known endpoints (#14605)Patrick Cloke2023-02-094-47/+63
| | | | | | | | Respond with a 405 error if a request is received on a known endpoint, but to an unknown method, per MSC3743.
* | Avoid mutating cached room aliases. (#15038)Patrick Cloke2023-02-091-1/+2
| | | | | | | | | | This might cause incorrect data in other callers which are not expecting the canonical alias to be added into the response.
* | Add final type hint to synapse.server. (#15035)Patrick Cloke2023-02-095-9/+10
| |
* | Limit concurrent event creation for a room to avoid state resolution when ↵Shay2023-02-081-3/+3
| | | | | | | | sending bursts of events to a local room (#14977)
* | MSC3873: Escape keys when flattening dicts. (#15004)Patrick Cloke2023-02-082-4/+31
| | | | | | | | | | | | This disambiguates keys which attempt to match fields with a dot in them (e.g. m.relates_to). Disabled by default behind an experimental configuration flag.
* | Merge branch 'release-v1.77' into developDavid Robertson2023-02-083-141/+7
|\|
| * Disambiguate `get_ex_outlier_stream_rows` queryDavid Robertson2023-02-071-4/+4
| | | | | | | | A backwards-compatible piece of #14979 that's safe to land now.
| * Revert "Add `event_stream_ordering` column to membership state tables (#14979)"David Robertson2023-02-074-145/+11
| | | | | | | | This reverts commit 5fdc12f482c68e2cdbb78d7db5de2cfe621720d4.
* | Typecheck tests.rest.media.v1.test_media_storage (#15008)David Robertson2023-02-071-4/+3
|/ | | | | | | | | | | * Fix MediaStorage type hint * Typecheck tests.rest.media.v1.test_media_storage * Changelog * Remove assert and make the comment succinct * Fix syntax for olddeps
* Add tests for using _flatten_dict with an event. (#15002)Patrick Cloke2023-02-071-8/+5
|
* Properly typecheck types.http (#14988)David Robertson2023-02-072-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Tweak http types in Synapse AFACIS these are correct, and they make mypy happier on tests.http. * Type hints for test_proxyagent * type hints for test_srv_resolver * test_matrix_federation_agent * tests.http.server._base * tests.http.__init__ * tests.http.test_additional_resource * tests.http.test_client * tests.http.test_endpoint * tests.http.test_matrixfederationclient * tests.http.test_servlet * tests.http.test_simple_client * tests.http.test_site * One fixup in tests.server * Untyped defs * Changelog * Fixup syntax for Python 3.7 * Fix olddeps syntax * Use a twisted IPv4 addr for dummy_address * Fix typo, thanks Sean Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Remove redundant `Optional` --------- Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Add `event_stream_ordering` column to membership state tables (#14979)Nick Mills-Barrett2023-02-074-11/+145
| | | | | | | | | | | | This adds an `event_stream_ordering` column to `current_state_events`, `local_current_membership` and `room_memberships`. Each of these tables is regularly joined with the `events` table to get the stream ordering and denormalising this into each table will yield significant query performance improvements once used. Includes a background job to populate these values from the `events` table. Same idea as https://github.com/matrix-org/synapse/pull/13703. Signed off by Nick @ Beeper (@fizzadar).
* Type hints for tests.appservice (#14990)David Robertson2023-02-064-7/+28
| | | | | | | | | | | | | | | | | | | | * Accept a Sequence of events in synapse.appservice This avoids some casts/ignores in the tests I'm about to fixup. It seems that `List[Mock]` is not a subtype of `List[EventBase]`, but `Sequence[Mock]` is a subtype of `Sequence[EventBase]`. So presumably `Mock` is considered a subtype of anything, much like `Any`. * make tests.appservice.test_scheduler pass mypy * Extra hints in tests.appservice.test_scheduler * Extra hints in tests.appservice.test_api * Extra hints in tests.appservice.test_appservice * Disallow untyped defs * Changelog
* Only notify the target of a membership event (#14971)David Robertson2023-02-061-8/+30
| | | | | * Only notify the target of a membership event Naughty, but should be a big speedup in large rooms
* Properly typecheck tests.api (#14983)David Robertson2023-02-031-2/+2
|
* Implement MSC3958: suppress notifications from edits (#14960)Patrick Cloke2023-02-032-0/+6
| | | | | | | | Co-authored-by: Brad Murray <brad@beeper.com> Co-authored-by: Nick Barrett <nick@beeper.com> Copy the suppress_edits push rule from Beeper to implement MSC3958. https://github.com/beeper/synapse/blame/9415a1284b1bfb558bd66f28c24ca1611e6c6fa2/rust/src/push/base_rules.rs#L98-L114
* Add a docstring & tests for _flatten_dict. (#14981)Patrick Cloke2023-02-031-0/+23
|
* Support the backwards compatibility features in MSC3952. (#14958)Patrick Cloke2023-02-031-1/+8
| | | | If the feature is enabled and the event has a `m.mentions` property, skip processing of the legacy mentions rules.
* Faster joins: Refactor handling of servers in room (#14954)Sean Quah2023-02-036-35/+74
| | | | | | | | | | | | | | Ensure that the list of servers in a partial state room always contains the server we joined off. Also refactor `get_partial_state_servers_at_join` to return `None` when the given room is no longer partial stated, to explicitly indicate when the room has partial state. Otherwise it's not clear whether an empty list means that the room has full state, or the room is partial stated, but the server we joined off told us that there are no servers in the room. Signed-off-by: Sean Quah <seanq@matrix.org>
* Reload the pyo3-log config when the Python logging config changes. (#14976)Patrick Cloke2023-02-031-18/+24
| | | | | | | | | | | Since pyo3-log is initialized very early in the Python start-up it caches the state of the loggers before they're fully initialized (and thus are essentially disabled). Whenever we reload the logging configuration we now also tell pyo3-log to discard any cached logging configuration it has; it will refetch the current logging configuration from Python at the next point it logs. This fixes Rust log lines not appearing in the homeserver logs.
* Skip unused calculations in sync handler. (#14908)Patrick Cloke2023-02-022-125/+136
| | | | | | | | | If a sync request does not need to calculate per-room entries & is not generating presence & is not generating device list data (e.g. during initial sync) avoid the expensive calculation of room specific data. This is a micro-optimisation for clients syncing simply to receive to-device information.
* Do not calculate presence or ephemeral events when they are filtered out ↵Patrick Cloke2023-02-021-10/+9
| | | | | | | | (#14970) This expands the previous optimisation from being only for initial sync to being for all sync requests. It also inverts some of the logic to be inclusive instead of exclusive.
* Fetch fewer events when getting hosts in room (#14962)David Robertson2023-02-021-2/+44
|
* Allow enabling the asyncio reactor in complement (#14858)realtyem2023-02-011-2/+19
| | | Signed-off-by: Jason Little realtyem@gmail.com
* Add helper to parse an enum from query args & use it. (#14956)Patrick Cloke2023-02-0123-95/+171
| | | | | | | | The `parse_enum` helper pulls an enum value from the query string (by delegating down to the parse_string helper with values generated from the enum). This is used to pull out "f" and "b" in most places and then we thread the resulting Direction enum throughout more code.
* Attempt to delete more duplicate rows in receipts_linearized table. (#14915)Patrick Cloke2023-02-011-8/+26
| | | | | | | | | The previous assumption was that the stream_id column was unique (for a room ID, receipt type, user ID tuple), but this turned out to be incorrect. Now find the max stream ID, then map this back to a database-specific row identifier and delete other rows which match the (room ID, receipt type, user ID) tuple, but *not* the row ID.
* Add more user information to export-data command. (#14894)Dirk Klimpel2023-02-012-1/+74
| | | | | | * The user's profile information. * The user's devices. * The user's connections / IP address information.
* Tag /send_join responses to detect faster joins (#14950)David Robertson2023-01-312-0/+11
| | | | | | | | | * Tag /send_join responses to detect faster joins * Changelog * Define a proper SynapseTag * isort
* Fix "Re-starting finished log context" spam when creating events (#14947)Sean Quah2023-01-311-1/+3
| | | | | | | | | | | `run_in_background` calls re-use the current logging context. When they are not awaited, they can complete after the current logging context has been marked as finished, which leads to log spam. Use `run_as_background_process` instead. Fixes one of the instances of #13090. Signed-off-by: Sean Quah <seanq@matrix.org>
* Make sqlite database migrations transactional again, part two (#14926)Sean Quah2023-01-313-5/+12
| | | | | | | | | | | | | | | | #14910 fixed the regression introduced by #13873 where sqlite database migrations would no longer run inside a transaction. However, it committed the transaction before Synapse updated its bookkeeping of which migrations have been run, which means that migrations may be run again after they have completed successfully. Leave the transaction open at the end of `executescript`, to restore the old, correct behaviour. Also make the PostgreSQL behaviour consistent with SQLite. Fixes #14909. Signed-off-by: Sean Quah <seanq@matrix.org>
* Reject boolean power levels (#14944)David Robertson2023-01-313-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Better test for bad values in power levels events The previous test only checked that Synapse didn't raise an exception, but didn't check that we had correctly interpreted the value of the dodgy power level. It also conflated two things: bad room notification levels, and bad user levels. There _is_ logic for converting the latter to integers, but we should test it separately. * Check we ignore types that don't convert to int * Handle `None` values in `notifications.room` * Changelog * Also test that bad values are rejected by event auth * Docstring * linter scripttttttttt * Test boolean values in PL content * Reject boolean power levels * Changelog
* Prefer `type(x) is int` to `isinstance(x, int)` (#14945)David Robertson2023-01-3113-47/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Perfer `type(x) is int` to `isinstance(x, int)` This covered all additional instances I could see where `x` was user-controlled. The remaining cases are ``` $ rg -s 'isinstance.*[^_]int' tests/replication/_base.py 576: if isinstance(obj, int): synapse/util/caches/stream_change_cache.py 136: assert isinstance(stream_pos, int) 214: assert isinstance(stream_pos, int) 246: assert isinstance(stream_pos, int) 267: assert isinstance(stream_pos, int) synapse/replication/tcp/external_cache.py 133: if isinstance(result, int): synapse/metrics/__init__.py 100: if isinstance(calls, (int, float)): synapse/handlers/appservice.py 262: assert isinstance(new_token, int) synapse/config/_util.py 62: if isinstance(p, int): ``` which cover metrics, logic related to `jsonschema`, and replication and data streams. AFAICS these are all internal to Synapse * Changelog
* Handle malformed values of `notification.room` in power level events (#14942)David Robertson2023-01-301-3/+16
| | | | | | | | | | | | | | | | | | | | | | | * Better test for bad values in power levels events The previous test only checked that Synapse didn't raise an exception, but didn't check that we had correctly interpreted the value of the dodgy power level. It also conflated two things: bad room notification levels, and bad user levels. There _is_ logic for converting the latter to integers, but we should test it separately. * Check we ignore types that don't convert to int * Handle `None` values in `notifications.room` * Changelog * Also test that bad values are rejected by event auth * Docstring * linter scripttttttttt
* Implement MSC3952: Intentional mentions (#14823)Patrick Cloke2023-01-274-1/+33
| | | | | | | | MSC3952 defines push rules which searches for mentions in a list of Matrix IDs in the event body, instead of searching the entire event body for display name / local part. This is implemented behind an experimental configuration flag and does not yet implement the backwards compatibility pieces of the MSC.
* Merge branch 'release-v1.76' into developDavid Robertson2023-01-274-11/+43
|\
| * Batch look-ups to see if rooms are partial stated. (#14917)Patrick Cloke2023-01-263-11/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Batch look-ups to see if rooms are partial stated. * Fix issues found in linting. * Fix typo. * Apply suggestions from code review Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Clarify comments. Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Also improve the cache size while we're at it * is_partial_state_rooms -> is_partial_state_room_batched * Run `black` * Improve annotation for `simple_select_many_batch` * Fix is_partial_state_room_batched impl * Okay, _actually_ fix impl * Update description. * Update synapse/storage/databases/main/room.py Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * Run black. Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> Co-authored-by: David Robertson <davidr@element.io>
| * Fix initialization of `_device_list_id_gen` (#14914)Sean Quah2023-01-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On startup, the `_device_list_id_gen` stream id generator is initialized using the maximum stream id seen in a list of tables. When we started populating the `device_list_remote_pending` table in #13913, we forgot to add it to the aforementioned list of tables, so the stream id generator can hand out old stream ids after a restart. The end result is that Synapse can fail to handle device list update EDUs after a restart when a partial state join is in progress. Add the `device_list_remote_pending` table to the list of tables to consider when initializing the `_device_list_id_gen` stream id generator. Signed-off-by: Sean Quah <seanq@matrix.org>
* | Use an enum for direction. (#14927)Patrick Cloke2023-01-278-44/+75
| | | | | | | | For better type safety we use an enum instead of strings to configure direction (backwards or forwards).
* | Add missing type hints in tests (#14879)Patrick Cloke2023-01-261-1/+2
| | | | | | | | * FIx-up type hints in tests.logging. * Add missing type hints to test_transactions.
* | Fix paginating /relations with a live token (#14866)Patrick Cloke2023-01-262-70/+122
| | | | | | | | | | The `/relations` endpoint was not properly handle "live tokens" (i.e sync tokens), to do this properly we abstract the code that `/messages` has and re-use it.
* | Use StrCollection in place of Collection[str] in (most) handlers code. (#14922)Patrick Cloke2023-01-2612-58/+42
| | | | | | | | Due to the increased safety of StrCollection over Collection[str] and Sequence[str].
* | Fix a bug in the send_local_online_presence_to module API (#14880)Patrick Cloke2023-01-254-11/+18
| | | | | | | | | | | | | | Destination was being used incorrectly (a single destination instead of a list of destinations was being passed). This also updates some of the types in the area to not use Collection[str], which is a footgun.
* | Add missing type hints for tests.events. (#14904)Patrick Cloke2023-01-251-1/+2
|/
* Bump the client-side timeout for /state (#14912)David Robertson2023-01-251-0/+4
| | | | | | | | | | | * Bump the client-side timeout for /state to allow faster joins resyncs the chance to complete for large rooms. We have seen this fair poorly (~90s for Matrix HQ's /state) in testing, causing the resync to advance to another HS who hasn't seen our join yet. * Changelog * Milliseconds!!!!
* Make sqlite database migrations transactional again (#14910)Sean Quah2023-01-252-2/+6
| | | | | | | | | | #13873 introduced a regression which causes sqlite database migrations to no longer run inside a transaction. Wrap them in a transaction again, to avoid database corruption when migrations are interrupted. Fixes #14909. Signed-off-by: Sean Quah <seanq@matrix.org>
* Request partial joins by default (#14905)David Robertson2023-01-242-7/+35
| | | | | | | | | | | | | | | | | | | | | | | | | * Request partial joins by default This is a little sloppy, but we are trying to gain confidence in faster joins in the upcoming RC. Admins can still opt out by adding the following to their Synapse config: ```yaml experimental: faster_joins: false ``` We may revert this change before the release proper, depending on how testing in the wild goes. * Changelog * Try to fix the backfill test failures * Upgrade notes * Postgres compat?
* Faster joins: omit partial rooms from eager syncs until the resync completes ↵David Robertson2023-01-239-36/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#14870) * Allow `AbstractSet` in `StrCollection` Or else frozensets are excluded. This will be useful in an upcoming commit where I plan to change a function that accepts `List[str]` to accept `StrCollection` instead. * `rooms_to_exclude` -> `rooms_to_exclude_globally` I am about to make use of this exclusion mechanism to exclude rooms for a specific user and a specific sync. This rename helps to clarify the distinction between the global config and the rooms to exclude for a specific sync. * Better function names for internal sync methods * Track a list of excluded rooms on SyncResultBuilder I plan to feed a list of partially stated rooms for this sync to ignore * Exclude partial state rooms during eager sync using the mechanism established in the previous commit * Track un-partial-state stream in sync tokens So that we can work out which rooms have become fully-stated during a given sync period. * Fix mutation of `@cached` return value This was fouling up a complement test added alongside this PR. Excluding a room would mean the set of forgotten rooms in the cache would be extended. This means that room could be erroneously considered forgotten in the future. Introduced in #12310, Synapse 1.57.0. I don't think this had any user-visible side effects (until now). * SyncResultBuilder: track rooms to force as newly joined Similar plan as before. We've omitted rooms from certain sync responses; now we establish the mechanism to reintroduce them into future syncs. * Read new field, to present rooms as newly joined * Force un-partial-stated rooms to be newly-joined for eager incremental syncs only, provided they're still fully stated * Notify user stream listeners to wake up long polling syncs * Changelog * Typo fix Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Unnecessary list cast Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Rephrase comment Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Another comment Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Fixup merge(?) * Poke notifier when receiving un-partial-stated msg over replication * Fixup merge whoops Thanks MV :) Co-authored-by: Mathieu Velen <mathieuv@matrix.org> Co-authored-by: Mathieu Velten <mathieuv@matrix.org> Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Skip processing stats for broken rooms. (#14873)Patrick Cloke2023-01-232-2/+17
| | | | | | | * Skip processing stats for broken rooms. * Newsfragment * Use a custom exception.
* Faster joins: Update room stats and the user directory on workers when ↵Sean Quah2023-01-233-5/+10
| | | | | | | | | | | | | | | | | | | | | | | finishing join (#14874) * Faster joins: Update room stats and user directory on workers when done When finishing a partial state join to a room, we update the current state of the room without persisting additional events. Workers receive notice of the current state update over replication, but neglect to wake the room stats and user directory updaters, which then get incidentally triggered the next time an event is persisted or an unrelated event persister sends out a stream position update. We wake the room stats and user directory updaters at the appropriate time in this commit. Part of #12814 and #12815. Signed-off-by: Sean Quah <seanq@matrix.org> * fixup comment Signed-off-by: Sean Quah <seanq@matrix.org>
* Enable Faster Remote Room Joins against worker-mode Synapse. (#14752)reivilibre2023-01-227-27/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Enable Complement tests for Faster Remote Room Joins on worker-mode * (dangerous) Add an override to allow Complement to use FRRJ under workers * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Fix race where we didn't send out replication notification * MORE HACKS * Fix get_un_partial_stated_rooms_token to take instance_name * Fix bad merge * Remove warning * Correctly advance un_partial_stated_room_stream * Fix merge * Add another notify_replication * Fixups * Create a separate ReplicationNotifier * Fix test * Fix portdb * Create a separate ReplicationNotifier * Fix test * Fix portdb * Fix presence test * Newsfile * Apply suggestions from code review * Update changelog.d/14752.misc Co-authored-by: Erik Johnston <erik@matrix.org> * lint Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> Co-authored-by: Erik Johnston <erik@matrix.org>
* Faster joins: Fix incompatibility with restricted joins (#14882)Sean Quah2023-01-222-81/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Avoid clearing out forward extremities when doing a second remote join When joining a restricted room where the local homeserver does not have a user able to issue invites, we perform a second remote join. We want to avoid clearing out forward extremities in this case because the forward extremities we have are up to date and clearing out forward extremities creates a window in which the room can get bricked if Synapse crashes. Signed-off-by: Sean Quah <seanq@matrix.org> * Do a full join when doing a second remote join into a full state room We cannot persist a partial state join event into a joined full state room, so we perform a full state join for such rooms instead. As a future optimization, we could always perform a partial state join and compute or retrieve the full state ourselves if necessary. Signed-off-by: Sean Quah <seanq@matrix.org> * Add lock around partial state flag for rooms Signed-off-by: Sean Quah <seanq@matrix.org> * Preserve partial state info when doing a second partial state join Signed-off-by: Sean Quah <seanq@matrix.org> * Add newsfile * Add a TODO(faster_joins) marker Signed-off-by: Sean Quah <seanq@matrix.org>
* Reduce max time we wait for stream positions (#14881)Erik Johnston2023-01-202-12/+11
| | | | | | Now that we wait for stream positions whenever we do a HTTP replication hit, we need to be less brutal in the case where we do timeout (as we have bugs around this).
* Always notify replication when a stream advances (#14877)Erik Johnston2023-01-2015-13/+89
| | | This ensures that all other workers are told about stream updates in a timely manner, without having to remember to manually poke replication.
* Faster joins: Avoid starting duplicate partial state syncs (#14844)Sean Quah2023-01-201-8/+98
| | | | | | | | | | | | | | | | | | Currently, we will try to start a new partial state sync every time we perform a remote join, which is undesirable if there is already one running for a given room. We intend to perform remote joins whenever additional local users wish to join a partial state room, so let's ensure that we do not start more than one concurrent partial state sync for any given room. ------------------------------------------------------------------------ There is a race condition where the homeserver leaves a room and later rejoins while the partial state sync from the previous membership is still running. There is no guarantee that the previous partial state sync will process the latest join, so we restart it if needed. Signed-off-by: Sean Quah <seanq@matrix.org>
* Fix bug in wait for stream position (#14872)Erik Johnston2023-01-191-10/+19
| | | | | | | This caused some requests to fail. This caused some requests to fail. This really only started causing issues due to #14856
* Implement MSC3930: polls push rules (#14787)Andrew Morgan2023-01-192-1/+9
|
* Wait for streams to catch up when processing HTTP replication. (#14820)Erik Johnston2023-01-1818-130/+211
| | | | This should hopefully mitigate a class of races where data gets out of sync due a HTTP replication request racing with the replication streams.
* Change default room version to 10. Implements MSC3904 (#14111)Catalan Lover2023-01-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change Documentation to have v10 as default room version * Change Default Room version to 10 * Add changelog entry for default room version swap * Add changelog entry for v10 default room version in docs * Clarify doc changelog entry Co-authored-by: David Robertson <david.m.robertson1@gmail.com> * Improve Documentation changes. Co-authored-by: David Robertson <david.m.robertson1@gmail.com> * Update Changelog entry to have correct format Co-authored-by: David Robertson <david.m.robertson1@gmail.com> * Update Spec Version to 1.5 * Only need 1 changelog. * Fix test. * Update "Changed in" line Co-authored-by: David Robertson <david.m.robertson1@gmail.com> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Patrick Cloke <patrickc@matrix.org>
* Properly check for frozendicts in event auth code. (#14864)Patrick Cloke2023-01-181-1/+2
| | | | | Check for for an instance of a mapping instead of a dict. This only affects room version 10 when frozen events are enabled.
* Stabilise serving partial join responses (#14839)David Robertson2023-01-172-12/+15
| | | | | Serving partial join responses is no longer experimental. They will only be served under the stable identifier if the the undocumented config flag experimental.msc3706_enabled is set to true. Synapse continues to request a partial join only if the undocumented config flag experimental.faster_joins is set to true; this setting remains present and unaffected.
* Fix bug in `wait_for_stream_position` (#14856)Erik Johnston2023-01-171-1/+1
| | | | | We were incorrectly checking if the *local* token had been advanced, rather than the token for the remote instance. In practice, I don't think this has caused any bugs due to where we use `wait_for_stream_position`, as critically we don't use it on instances that also write to the given streams (and so the local token will lag behind all remote tokens).
* Merge device list replication streams (#14833)Erik Johnston2023-01-174-33/+65
|
* Add parameter to control whether we do a partial state join (#14843)Sean Quah2023-01-162-5/+23
| | | | | | | When the local homeserver is already joined to a room and wants to perform another remote join, we may find it useful to do a non-partial state join if we already have the full state for the room. Signed-off-by: Sean Quah <seanq@matrix.org>
* Add an early return when handling no-op presence updates. (#14855)Erik Johnston2023-01-161-0/+5
| | | This stops us from incrementing the presence stream position for no-op updates.
* Remove unnecessary reactor reference from `_PerHostRatelimiter` (#14842)Sean Quah2023-01-163-10/+2
| | | | | Fix up #14812 to avoid introducing a reference to the reactor. Signed-off-by: Sean Quah <seanq@matrix.org>
* Also use stable name in SendJoinResponse struct (#14841)David Robertson2023-01-163-11/+13
| | | | | | | | | | | | | | | | | * Also use stable name in SendJoinResponse struct follow-up to #14832 * Changelog * Fix a rename I missed * Run black * Update synapse/federation/federation_client.py Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Implement MSC3890: Remotely silence local notifications (#14775)Andrew Morgan2023-01-132-1/+25
|
* Use stable identifiers for faster joins (#14832)David Robertson2023-01-133-3/+30
| | | | | | | | | | | * Use new query param when requesting a partial join * Read new query param when serving partial join * Provide new field names when serving partial joins * Read new field names from partial join response * Changelog
* Merge account data streams (#14826)Erik Johnston2023-01-1310-83/+62
|
* Drop unused table `presence` (#14825)Dirk Klimpel2023-01-131-0/+17
|
* Add some clarifying comments and refactor a portion of the `Keyring` class ↵Andrew Morgan2023-01-131-18/+43
| | | | for readability (#14804)
* Fix stack overflow in `_PerHostRatelimiter` due to synchronous requests (#14812)Sean Quah2023-01-133-9/+27
| | | | | | | | | | | | | | | | | | When there are many synchronous requests waiting on a `_PerHostRatelimiter`, each request will be started recursively just after the previous request has completed. Under the right conditions, this leads to stack exhaustion. A common way for requests to become synchronous is when the remote client disconnects early, because the homeserver is overloaded and slow to respond. Avoid stack exhaustion under these conditions by deferring subsequent requests until the next reactor tick. Fixes #14480. Signed-off-by: Sean Quah <seanq@matrix.org>
* Merge remote-tracking branch 'origin/release-v1.75' into developRichard van der Hoff2023-01-123-13/+59
|\
| * Fix race calling `/members?at=` (#14817)Erik Johnston2023-01-121-6/+59
| | | | | | Fixes #14814
| * Calculate rooms changed for device lists to work. (#14810)Patrick Cloke2023-01-112-7/+0
| | | | | | | | Back-out some changes from 7e582a25f8f350df29d7d83ca902bdb522d1bbaf (#14786) which skipped necessary logic to calculate device lists properly.
* | Re-enable some linting (#14821)Erik Johnston2023-01-121-6/+4
| | | | | | | | | | | | | | * Re-enable some linting * Newsfile * Remove comment
* | Add `set_displayname` to the module API (#14629)Emelie Graven2023-01-111-0/+27
| |
* | Faster remote room joins (worker mode): do not populate external ↵reivilibre2023-01-111-5/+16
| | | | | | | | | | | | hosts-in-room cache when sending events as this requires blocking for full state. (#14749) Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> Co-authored-by: Sean Quah <seanq@matrix.org>
* | Add index to improve performance of the `/timestamp_to_event` endpoint used ↵reivilibre2023-01-112-0/+29
| | | | | | | | for jumping to a specific date in the timeline of a room. (#14799)
* | Add listener `health` (#14747)Dirk Klimpel2023-01-112-0/+6
| | | | | | Fixes: #8780
* | Implement MSC3925: changes to bundling of edits (#14811)Richard van der Hoff2023-01-103-8/+28
|/ | | | | | | | Two parts to this: * Bundle the whole of the replacement with any edited events. This is backwards-compatible so I haven't put it behind a flag. * Optionally, inhibit server-side replacement of edited events. This has scope to break things, so it is currently disabled by default.
* Batch up replication requests to request the resyncing of remote users's ↵reivilibre2023-01-108-79/+305
| | | | devices. (#14716)
* Remove undocumented device from pushrules (#14727)Jeyachandran Rathnam2023-01-091-4/+1
| | | | | | | | | | | * Remove undocumented device from pushrules * Add changelog * Update changelog.d/14727.misc * Rename 14727.misc to 14727.bugfix Co-authored-by: David Robertson <davidr@element.io>
* Unescape HTML entities in oEmbed titles. (#14781)Jeyachandran Rathnam2023-01-091-6/+9
| | | | | | | It doesn't seem valid that HTML entities should appear in the title field of oEmbed responses, but a popular WordPress plug-in seems to do it. There should not be harm in unescaping these.
* Improve /sync performance of when passing filters with empty arrays. (#14786)Patrick Cloke2023-01-093-9/+20
| | | | | | | | | | | | | | | | This has two related changes: * It enables fast-path processing for an empty filter (`[]`) which was previously only used for wildcard not-filters (`["*"]`). * It special cases a `/sync` filter with no-rooms to skip all room processing, previously we would partially skip processing, but would generally still calculate intermediate values for each room which were then unused. Future changes might consider further optimizations: * Skip calculating per-room account data when all rooms are filtered (currently this is thrown away). * Make similar improvements to other endpoints which support filters.
* Disable sending confirmation email when 3pid is disabled #14682 (#14725)Jeyachandran Rathnam2023-01-091-0/+5
| | | | | | | | | | | * Fixes #12277 :Disable sending confirmation email when 3pid is disabled * Fix test_add_email_if_disabled test case to reflect changes to enable_3pid_changes flag * Add changelog file * Rename newsfragment. Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Support RFC7636 PKCE in the OAuth 2.0 flow. (#14750)Patrick Cloke2023-01-043-7/+60
| | | | | | | PKCE can protect against certain attacks and is enabled by default. Support can be controlled manually by setting the pkce_method of each oidc_providers entry to 'auto' (default), 'always', or 'never'. This is required by Twitter OAuth 2.0 support.
* Support non-OpenID compliant user info endpoints (#14753)Patrick Cloke2023-01-041-8/+23
| | | | | | | | OpenID specifies the format of the user info endpoint and some OAuth 2.0 IdPs do not follow it, e.g. NextCloud and Twitter. This adds subject_template and picture_template options to the default mapping provider for more flexibility in matching those user info responses.
* Update all stream IDs after processing replication rows (#14723)Nick Mills-Barrett2023-01-0412-20/+94
| | | | | | | | | | | | | | This creates a new store method, `process_replication_position` that is called after `process_replication_rows`. By moving stream ID advances here this guarantees any relevant cache invalidations will have been applied before the stream is advanced. This avoids race conditions where Python switches between threads mid way through processing the `process_replication_rows` method where stream IDs may be advanced before caches are invalidated due to class resolution ordering. See this comment/issue for further discussion: https://github.com/matrix-org/synapse/issues/14158#issuecomment-1344048703
* Add experimental support for MSC3391: deleting account data (#14714)Andrew Morgan2023-01-016-30/+543
|
* Actually use the picture_claim as configured in OIDC config. (#14751)Patrick Cloke2022-12-291-1/+1
| | | | Previously it was only using the default value ("picture") when fetching the picture from the user info.
* Add a `cached` helper to the module API (#14663)Brendan Abolivier2022-12-281-1/+39
|
* Log to-device msgids when we return them over /sync (#14724)Richard van der Hoff2022-12-231-7/+13
|
* Check sqlite database file exists before porting. (#14692)Jeyachandran Rathnam2022-12-221-1/+1
| | | | To avoid creating an empty SQLite file if the given path is incorrect.
* Switch to ruff instead of flake8. (#14633)Patrick Cloke2022-12-211-0/+2
| | | | | ruff is a flake8-compatible Python linter written in Rust. It supports the flake8 plugins that we use and is significantly faster in testing.
* Faster remote room joins: invalidate caches and unblock requests when ↵reivilibre2022-12-193-14/+45
| | | | receiving un-partial-stated event notifications over replication. [rei:frrj/streams/unpsr] (#14546)
* Add missing type hints to tests.config. (#14681)Patrick Cloke2022-12-162-9/+4
|
* Improve type annotations for the helper methods on a `CachedFunction`. (#14685)reivilibre2022-12-161-3/+3
|
* Add missing type hints to tests.handlers. (#14680)Patrick Cloke2022-12-161-1/+1
| | | And do not allow untyped defs in tests.handlers.
* Make `handle_new_client_event` throws `PartialStateConflictError` (#14665)Mathieu Velten2022-12-156-239/+359
| | | | | | | Then adapts calling code to retry when needed so it doesn't 500 to clients. Signed-off-by: Mathieu Velten <mathieuv@matrix.org> Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Allow `compute_state_after_events` to use partial state (#14676)David Robertson2022-12-141-2/+8
| | | | | | | * Allow `compute_state_after_events` to use partial state if fetching a subset of state that is trusted during a partial join. * Changelog
* Faster remote room joins: stream the un-partial-stating of events over ↵reivilibre2022-12-147-10/+203
| | | | replication. [rei:frrj/streams/unpsr] (#14545)
* Delete event_push_summary_unique_index again. (#14669)Patrick Cloke2022-12-142-9/+33
| | | | | | | | | | | | | | | | | | if a Synapse deployment upgraded (from < 1.62.0 to >= 1.70.0) then it is possible for schema deltas to run before background updates causing drift in the database schema due to: 1. A delta registered a background update to create an index. 2. A delta dropped the above index if it exists (but it yet exist won't since the background job hasn't run). 3. The code assumed the index was dropped. To fix this we: 1. Cancel the background update which could create the index. 2. Drop the index again. 3. Drop a related index which is dropped by the background update.
* Fix #11308 : Remove dependency on jquery on reCAPTCHA page (#14672)Jeyachandran Rathnam2022-12-141-2/+1
|
* Use the room type from stats in hierarchy response. (#14263)Patrick Cloke2022-12-131-9/+5
| | | | | | | | | This avoids pulling additional state information (and events) from the database for each item returned in the hierarchy response. The room type might be out of date until a background update finishes running, the worst impact of this would be spaces being treated as rooms in the hierarchy response. This should self-heal once the background update finishes.
* Improve validation of field size limits in events. (#14664)reivilibre2022-12-136-29/+117
|
* Allow selecting "prejoin" events by state keys (#14642)David Robertson2022-12-136-47/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Declare new config * Parse new config * Read new config * Don't use trial/our TestCase where it's not needed Before: ``` $ time trial tests/events/test_utils.py > /dev/null real 0m2.277s user 0m2.186s sys 0m0.083s ``` After: ``` $ time trial tests/events/test_utils.py > /dev/null real 0m0.566s user 0m0.508s sys 0m0.056s ``` * Helper to upsert to event fields without exceeding size limits. * Use helper when adding invite/knock state Now that we allow admins to include events in prejoin room state with arbitrary state keys, be a good Matrix citizen and ensure they don't accidentally create an oversized event. * Changelog * Move StateFilter tests should have done this in #14668 * Add extra methods to StateFilter * Use StateFilter * Ensure test file enforces typed defs; alphabetise * Workaround surprising get_current_state_ids * Whoops, fix mypy
* Enable `--warn-redundant-casts` option in mypy (#14671)David Robertson2022-12-122-2/+3
| | | | | | | | | | | | | | | | | | | * Enable `--warn-redundant-casts` option in mypy Doesn't do much but helps me sleep better at night. * Changelog * Fix name of the ignore * Fix one more missed cast Not sure why I didn't see this one locally, maybe I needed a poetry update * Remove old comment Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Fix missing cache invalidation in application service code (#14670)Sean Quah2022-12-121-2/+6
| | | | | | | | | | | | #11915 introduced the `@cached` `is_interested_in_room` method in Synapse 1.55.0, which depends upon `get_aliases_for_room`. Add a missing cache invalidation callback so that the `is_interested_in_room` cache is invalidated when `get_aliases_for_room` is invalidated. #13787 made `get_rooms_for_user` `@cached`. Add a missing cache invalidation callback so that the `is_interested_in_presence` cache is invalidated when `get_rooms_for_user` is invalidated. Signed-off-by: Sean Quah <seanq@matrix.org>
* Move `StateFilter` to `synapse.types` (#14668)David Robertson2022-12-1225-23/+23
| | | | | * Move `StateFilter` to `synapse.types` * Changelog
* Revert the deletion of stale devices due to performance issues. (#14662)reivilibre2022-12-122-115/+2
|
* Add optional ICU support for user search (#14464)Brendan Abolivier2022-12-121-4/+63
| | | | | | | Fixes #13655 This change uses ICU (International Components for Unicode) to improve boundary detection in user search. This change also adds a new dependency on libicu-dev and pkg-config for the Debian packages, which are available in all supported distros.
* Handle half-created indices in receipts index background update (#14650)Sean Quah2022-12-092-48/+58
| | | | | | | | | | | | | When Synapse is terminated while running the background update to create the `receipts_graph` or `receipts_linearized` indexes, the indexes may be successfully created (or marked as invalid on postgres) while the background update remains unfinished. When Synapse next starts up, the background update will fail because the index already exists, or exists but is invalid on postgres. Use the existing code to create indices in background updates, since it handles these edge cases. Signed-off-by: Sean Quah <seanq@matrix.org>
* Require types in tests.storage. (#14646)Patrick Cloke2022-12-091-1/+1
| | | | Adds missing type hints to `tests.storage` package and does not allow untyped definitions.
* Limit the number of devices we delete at once (#14649)Erik Johnston2022-12-092-4/+11
|
* Delete stale non-e2e devices for users, take 2 (#14595)Erik Johnston2022-12-092-2/+108
| | | | | This should help reduce the number of devices e.g. simple bots the repeatedly login rack up. We only delete non-e2e devices as they should be safe to delete, whereas if we delete e2e devices for a user we may accidentally break their ability to receive e2e keys for a message.
* Fix html templates to load images only on HTTPS (#14625)Ashish Kumar2022-12-083-9/+9
| | | | | | | | | | This PR changes http-based image URLs to be https in html templates. This impacts the Synapse SSO error page, where browsers report mixed media content warnings. Also, https://matrix.org/img/vector-logo-email.png is currently broken but the URL has been updated to be https anyway. Signed-off-by: Ashish Kumar <ashfame@users.noreply.github.com>
* Rebuild the user directory and stats tables. (#14643)Patrick Cloke2022-12-081-0/+29
| | | | | | | | | | | Due to the various fixes to the StreamChangeCache it is not safe to trust the information in the user directory or room/user stats tables. Rebuild them as background jobs. In particular see da777207528513c858395758bf4c023da2c2c1a3 (#14639), and 6a8310f3dfe77acf59df2fe3e88a71b85b9b3ecc (#14435). Maybe also be related to fac8a38525387e344e3595a092578e0ffedd49ae (#14592).
* Respond with proper error responses on unknown paths. (#14621)Patrick Cloke2022-12-084-9/+26
| | | | Returns a proper 404 with an errcode of M_RECOGNIZED for unknown endpoints per MSC3743.
* Check the stream position before checking if the cache is empty. (#14639)Patrick Cloke2022-12-081-4/+5
| | | | | | An empty cache does not mean the entity has no changed, if it is earlier than the earliest known stream position return that the entity *has* changed since the cache cannot accurately answer that query.
* Reject receipt requests with invalid room or event IDs. (#14632)Nick Mills-Barrett2022-12-071-1/+4
| | | | If the room or event IDs are empty or of an invalid form they should be rejected.
* Fix a bug introduced in v1.67.0 where not specifying a config file or a ↵reivilibre2022-12-071-2/+3
| | | | server URL would lead to the `register_new_matrix_user` script failing. (#14637)
* Fix a long-standing bug where the user directory would return 1 more row ↵reivilibre2022-12-072-3/+3
| | | | than requested. (#14631)
* Faster remote room joins: unblock tasks waiting for full room state when the ↵reivilibre2022-12-061-0/+11
| | | | un-partial-stating of that room is received over the replication stream. [rei:frrj/streams/unpsr] (#14474)
* Failover on proper error responses. (#14620)Patrick Cloke2022-12-061-9/+20
| | | | When querying a remote server handle a 404/405 with an errcode of M_UNRECOGNIZED as an unimplemented endpoint.
* Improve logging and opentracing for to-device message handling (#14598)Richard van der Hoff2022-12-068-45/+129
| | | | | | | A batch of changes intended to make it easier to trace to-device messages through the system. The intention here is that a client can set a property org.matrix.msgid in any to-device message it sends. That ID is then included in any tracing or logging related to the message. (Suggestions as to where this field should be documented welcome. I'm not enthusiastic about speccing it - it's very much an optional extra to help with debugging.) I've also generally improved the data we send to opentracing for these messages.
* Better return type for `get_all_entities_changed` (#14604)Erik Johnston2022-12-056-68/+125
| | | | Help callers from using the return value incorrectly by ensuring that callers explicitly check if there was a cache hit or not.
* Compare to the earliest known stream pos in the stream change cache. (#14435)Patrick Cloke2022-12-051-26/+116
| | | | | | The internal methods of the StreamChangeCache were inconsistently treating the earliest known stream position as valid. It is now treated as invalid, meaning the cache cannot determine if an entity at the earliest known stream position has changed or not.
* Faster remote room joins: stream the un-partial-stating of rooms over ↵reivilibre2022-12-057-67/+279
| | | | replication. [rei:frrj/streams/unpsr] (#14473)
* Suppress empty body warnings in room servelets (#14600)David Robertson2022-12-051-12/+2
| | | | | | | | | * Suppress empty body warnings in room servelets We've already decided to allow empty bodies for backwards compat. The change here stops us from emitting a misleading warning; see also https://github.com/matrix-org/synapse/issues/14478#issuecomment-1319157105 * Changelog
* Use ClientRestResource on both the main process and workers. (#14528)Patrick Cloke2022-12-027-119/+70
| | | | | | | Add logic to ClientRestResource to decide whether to mount servlets or not based on whether the current process is a worker. This is clearer to see what a worker runs than the completely separate / copy & pasted list of servlets being mounted for workers.
* Properly handle unknown results for the stream change cache. (#14592)Patrick Cloke2022-12-022-16/+21
| | | | | | StreamChangeCache.get_all_changed_entities can return None to signify it does not have information at the given stream position. Two callers (related to device lists and presence) were treating this response the same as an empty list (i.e. there being no updates).
* Add `push.enabled` option to disable push notification calculation (#14551)Will Hunt2022-12-012-0/+4
| | | | | | | * Add initial option * changelog * Some more linting
* Merge branch 'release-v1.73' into developDavid Robertson2022-12-012-78/+2
|\
| * Revert "POC delete stale non-e2e devices for users (#14038)" (#14582)David Robertson2022-11-292-79/+2
| |
| * Fix `UndefinedColumn: column "key_json" does not exist` errors when handling ↵David Robertson2022-11-291-0/+1
| | | | | | | | users with more than 50 non-E2E devices (#14580)
* | Aggregate unread notif count query for badge count calculation (#14255)Nick Mills-Barrett2022-11-302-19/+158
| | | | | | | | | | | | Fetch the unread notification counts used by the badge counts in push notifications for all rooms at once (instead of fetching them per room).
* | Use servers list approx to send read receipts when in partial state (#14549)Mathieu Velten2022-11-301-1/+1
| | | | | | Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
* | Stop using deprecated `keyIds` param on /key/v2/server (#14525)Richard van der Hoff2022-11-301-64/+43
| | | | | | | | Fixes #14523.
* | Advertise support for Matrix v1.5. (#14576)Patrick Cloke2022-11-291-0/+1
|/ | | | All features of Matrix v1.5 were already supported: this was mostly a maintenance release.
* POC delete stale non-e2e devices for users (#14038)Erik Johnston2022-11-292-2/+78
| | | | | | | | This should help reduce the number of devices e.g. simple bots the repeatedly login rack up. We only delete non-e2e devices as they should be safe to delete, whereas if we delete e2e devices for a user we may accidentally break their ability to receive e2e keys for a message. Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Fix possible variable shadow in `create_new_client_event` (#14575)Shay2022-11-281-2/+4
|
* Support MSC1767's `content.body` behaviour; Add base rules from MSC3933 (#14524)Travis Ralston2022-11-282-2/+32
| | | | | | | | | | | * Support MSC1767's `content.body` behaviour in push rules * Add the base rules from MSC3933 * Changelog entry * Flip condition around for finding `m.markup` * Remove forgotten import
* Create MSC1767 (extensible events) room version; Implement MSC3932 (#14521)Travis Ralston2022-11-282-1/+33
| | | | | | | | | | | | * Add MSC1767's dedicated room version, based on v10 * Only enable MSC1767 room version if the config flag is on Using a similar technique to knocking: https://github.com/matrix-org/synapse/pull/6739/files#diff-3af529eedb0e00279bafb7369370c9654b37792af8eafa0925400e9281d57f0a * Support MSC3932: Extensible events room version feature flag * Changelog entry
* Initial support for MSC3931: Room version push rule feature flags (#14520)Travis Ralston2022-11-283-1/+29
| | | | | | | * Add support for MSC3931: Room Version Supports push rule condition * Create experimental flag for future work, and use it to gate MSC3931 * Changelog entry
* Move MSC3030 `/timestamp_to_event` endpoint to stable v1 location (#14471)Eric Eastwood2022-11-287-26/+17
| | | | | | | | Fix https://github.com/matrix-org/synapse/issues/14390 - Client API: `/_matrix/client/unstable/org.matrix.msc3030/rooms/<roomID>/timestamp_to_event?ts=<timestamp>&dir=<direction>` -> `/_matrix/client/v1/rooms/<roomID>/timestamp_to_event?ts=<timestamp>&dir=<direction>` - Federation API: `/_matrix/federation/unstable/org.matrix.msc3030/timestamp_to_event/<roomID>?ts=<timestamp>&dir=<direction>` -> `/_matrix/federation/v1/timestamp_to_event/<roomID>?ts=<timestamp>&dir=<direction>` Complement test changes: https://github.com/matrix-org/complement/pull/559
* Use `device_one_time_keys_count` to match MSC3202 (#14565)Andrew Ferrazzutti2022-11-286-29/+32
| | | | | | | | | | | | | | | | | | | * Use `device_one_time_keys_count` to match MSC3202 Rename the `device_one_time_key_counts` key in responses to `device_one_time_keys_count` to match the name specified by MSC3202. Also change related variable/class names for consistency. Signed-off-by: Andrew Ferrazzutti <andrewf@element.io> * Update changelog.d/14565.misc * Revert name change for `one_time_key_counts` key as this is a different key altogether from `device_one_time_keys_count`, which is used for `/sync` instead of appservice transactions. Signed-off-by: Andrew Ferrazzutti <andrewf@element.io>
* Fix logging context warnings due to common usage metrics setup (#14574)Sean Quah2022-11-281-1/+3
| | | | | | | | | `setup()` is run under the sentinel context manager, so we wrap the initial update in a background process. Before this change, Synapse would log two warnings on startup: Starting db txn 'count_daily_users' from sentinel context Starting db connection from sentinel context: metrics will be lost Signed-off-by: Sean Quah <seanq@matrix.org>
* Include thread information when sending receipts over federation. (#14466)Patrick Cloke2022-11-282-64/+120
| | | | | | | | | | | | Include the thread_id field when sending read receipts over federation. This might result in the same user having multiple read receipts per-room, meaning multiple EDUs must be sent to encapsulate those receipts. This restructures the PerDestinationQueue APIs to support multiple receipt EDUs, queue_read_receipt now becomes linear time in the number of queued threaded receipts in the room for the given user, it is expected this is a small number since receipt EDUs are sent as filler in transactions.
* Remove option to skip locking of tables during emulated upserts (#14469)Sean Quah2022-11-289-74/+18
| | | | | | | | | | | | | | | | | | To perform an emulated upsert into a table safely, we must either: * lock the table, * be the only writer upserting into the table * or rely on another unique index being present. When the 2nd or 3rd cases were applicable, we previously avoided locking the table as an optimization. However, as seen in #14406, it is easy to slip up when adding new schema deltas and corrupt the database. The only time we lock when performing emulated upserts is while waiting for background updates on postgres. On sqlite, we do no locking at all. Let's remove the option to skip locking tables, so that we don't shoot ourselves in the foot again. Signed-off-by: Sean Quah <seanq@matrix.org>
* Add support for handling avatar with SSO login (#13917)Ashish Kumar2022-11-252-0/+118
| | | | | | | | This commit adds support for handling a provided avatar picture URL when logging in via SSO. Signed-off-by: Ashish Kumar <ashfame@users.noreply.github.com> Fixes #9357.
* Faster joins: use initial list of servers if we don't have the full state ↵Mathieu Velten2022-11-241-1/+17
| | | | | | | yet (#14408) Signed-off-by: Mathieu Velten <mathieuv@matrix.org> Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Fix crash admin media list api when info is None (#14537)schmop2022-11-241-1/+5
| | | Fixes https://github.com/matrix-org/synapse/issues/14536
* Implement message forward pagination from start when no from is given, fixes ↵Benjamin Kampmann2022-11-242-0/+19
| | | | | #12383 (#14149) Fixes https://github.com/matrix-org/synapse/issues/12383
* Remove legacy Prometheus metrics names. They were deprecated in Synapse ↵reivilibre2022-11-247-310/+43
| | | | v1.69.0 and disabled by default in Synapse v1.71.0. (#14538)
* Faster joins: use servers list approximation in `assert_host_in_room` (#14515)Mathieu Velten2022-11-241-11/+17
| | | Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
* Add another index to `device_lists_changes_in_room` (#14534)Erik Johnston2022-11-232-0/+27
| | | | This helps avoid reading unnecessarily large amounts of data from the table when querying with a set of room IDs.
* Optimize `filter_events_for_client` for faster `/messages` - v2 (#14527)Eric Eastwood2022-11-221-20/+79
| | | Fix #14108
* Refactor `federation_sender` and `pusher` configuration loading. (#14496)realtyem2022-11-221-69/+70
| | | | | | To avoid duplicating the same logic for handling legacy configuration settings. This should help in applying similar logic to other worker types.
* Add a type hint for `get_device_handler()` and fix incorrect types. (#14055)Patrick Cloke2022-11-2213-70/+167
| | | | | This was the last untyped handler from the HomeServer object. Since it was being treated as Any (and thus unchecked) it was being used incorrectly in a few places.
* Track unconverted device list outbound pokes using a position instead (#14516)Sean Quah2022-11-224-47/+156
| | | | | | | | | | | | | | | | | | | | | When a local device list change is added to `device_lists_changes_in_room`, the `converted_to_destinations` flag is set to `FALSE` and the `_handle_new_device_update_async` background process is started. This background process looks for unconverted rows in `device_lists_changes_in_room`, copies them to `device_lists_outbound_pokes` and updates the flag. To update the `converted_to_destinations` flag, the database performs a `DELETE` and `INSERT` internally, which fragments the table. To avoid this, track unconverted rows using a `(stream ID, room ID)` position instead of the flag. From now on, the `converted_to_destinations` column indicates rows that need converting to outbound pokes, but does not indicate whether the conversion has already taken place. Closes #14037. Signed-off-by: Sean Quah <seanq@matrix.org>
* Parallelize calls to fetch bundled aggregations. (#14510)Patrick Cloke2022-11-221-32/+51
| | | | The bundled aggregations for annotations, references, and edits can be parallelized.
* Batch fetch bundled references (#14508)Patrick Cloke2022-11-224-77/+130
| | | | | | | | | Avoid an n+1 query problem and fetch the bundled aggregations for m.reference relations in a single query instead of a query per event. This applies similar logic for as was previously done for edits in 8b309adb436c162510ed1402f33b8741d71fc058 (#11660; threads in b65acead428653b988351ae8d7b22127a22039cd (#11752); and annotations in 1799a54a545618782840a60950ef4b64da9ee24d (#14491).
* Batch fetch bundled annotations (#14491)Patrick Cloke2022-11-223-139/+199
| | | | | | | | Avoid an n+1 query problem and fetch the bundled aggregations for m.annotation relations in a single query instead of a query per event. This applies similar logic for as was previously done for edits in 8b309adb436c162510ed1402f33b8741d71fc058 (#11660) and threads in b65acead428653b988351ae8d7b22127a22039cd (#11752).
* Faster joins: filter out non local events when a room doesn't have its full ↵Mathieu Velten2022-11-213-8/+37
| | | | | | state (#14404) Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
* Fix /key/v2/server calls with URL-unsafe key IDs (#14490)David Robertson2022-11-181-1/+1
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Reduce default third party invite rate limit to 216 invites per day (#14487)Sean Quah2022-11-181-4/+1
| | | | | | The previous default was the same as the `rc_message` rate limit, which defaults to 17,280 per day. Signed-off-by: Sean Quah <seanq@matrix.org>
* Fix version that `worker_main_http_uri` is redundant from (#14476)David Robertson2022-11-171-1/+1
| | | | | * Fix version that `worker_main_http_uri` is redundant from * Changelog
* Fix check to ignore blank lines in incoming TCP replication (#14449)Andrew Morgan2022-11-172-4/+4
|
* Faster joins: do not wait for full state when creating events to send (#14403)Mathieu Velten2022-11-172-1/+8
| | | Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
* Reintroduce #14376, with bugfix for monoliths (#14468)David Robertson2022-11-1610-176/+73
| | | | | | | | | | | | | | | | | | | | | | * Add tests for StreamIdGenerator * Drive-by: annotate all defs * Revert "Revert "Remove slaved id tracker (#14376)" (#14463)" This reverts commit d63814fd736fed5d3d45ff3af5e6d3bfae50c439, which in turn reverted 36097e88c4da51fce6556a58c49bd675f4cf20ab. This restores the latter. * Fix StreamIdGenerator not handling unpersisted IDs Spotted by @erikjohnston. Closes #14456. * Changelog Co-authored-by: Nick Mills-Barrett <nick@fizzadar.com> Co-authored-by: Erik Johnston <erik@matrix.org>
* Remove need for `worker_main_http_uri` setting to use /keys/upload. (#14400)realtyem2022-11-164-119/+125
|
* Fix an invalid comparison of `UserPresenceState` to `str` (#14393)Andrew Morgan2022-11-161-1/+1
|
* Remove redundant types from comments. (#14412)Patrick Cloke2022-11-1649-150/+143
| | | | | | | Remove type hints from comments which have been added as Python type hints. This helps avoid drift between comments and reality, as well as removing redundant information. Also adds some missing type hints which were simple to fill in.
* Fix background updates failing to add unique indexes on receipts (#14453)Sean Quah2022-11-161-24/+147
| | | | | | | | | | | | | | | | | | | | | | As part of the database migration to support threaded receipts, there is a possible window in between `73/08thread_receipts_non_null.sql.postgres` removing the original unique constraints on `receipts_linearized` and `receipts_graph` and the `reeipts_linearized_unique_index` and `receipts_graph_unique_index` background updates from `72/08thread_receipts.sql` completing where the unique constraints on `receipts_linearized` and `receipts_graph` are missing. Any emulated upserts on these tables must therefore be performed with a lock held, otherwise duplicate rows can end up in the tables when there are concurrent emulated upserts. Fix the missing lock. Note that emulated upserts no longer happen by default on sqlite, since the minimum supported version of sqlite supports native upserts by default now. Finally, clean up any duplicate receipts that may have crept in before trying to create the `receipts_graph_unique_index` and `receipts_linearized_unique_index` unique indexes. Signed-off-by: Sean Quah <seanq@matrix.org>
* Revert "Remove slaved id tracker (#14376)" (#14463)Erik Johnston2022-11-1610-73/+176
| | | This reverts commit 36097e88c4da51fce6556a58c49bd675f4cf20ab.
* Don't filter state in /context response (#14461)Erik Johnston2022-11-161-1/+1
| | | We don't filter state usually, so doing so here is a waste of time. This is not much of an issue for clients that enable lazy loading of members, since there will be fewer state events.
* Fix HTML templates missing correct HTML tags (#14448)Erik Johnston2022-11-1621-0/+22
|
* Include heroes in partial join responses' state (#14442)David Robertson2022-11-153-21/+52
| | | | | | | | | | | * Pull out hero selection logic * Include heroes in partial join response's state * Changelog * Fixup trial test * Remove TODO
* Fix typechecking errors introduced in #14128 (#14455)David Robertson2022-11-152-4/+5
| | | | | | | | | * Fix typechecking errors introduced in #14128 * Changelog * Correct annotations so that context_factory works if you don't use TLS
* Send content rules with pattern_type to clients (#14356)DeepBlueV7.X2022-11-151-3/+13
|
* Support using SSL on worker endpoints. (#14128)Tuomas Ojamies2022-11-155-53/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix missing SSL support in worker endpoints. * Add changelog * SSL for Replication endpoint * Remove unit test change * Refactor listener creation to reduce duplicated code * Fix the logger message * Update synapse/app/_base.py Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * Update synapse/app/_base.py Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * Update synapse/app/_base.py Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * Add config documentation for new TLS option Co-authored-by: Tuomas Ojamies <tojamies@palantir.com> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Update docstring to clarify that `get_partial_state_events_batch` does not ↵reivilibre2022-11-151-1/+9
| | | | just give you completely arbitrary partial-state events. (#14417)
* Remove slaved id tracker (#14376)Nick Mills-Barrett2022-11-1410-176/+73
| | | | | This matches the multi instance writer ID generator class which can both handle advancing the current token over replication and by calling the database.
* Remove unused type-ignores (#14433)David Robertson2022-11-141-3/+6
| | | | | | | * Remove unused type-ignores Oversights in #14427 and #14429. * Changelog
* Clean-up events persistance code (#14411)Patrick Cloke2022-11-142-8/+3
| | | | By removing unused variables and making some arguments required which are always provided.
* Add an Admin API endpoint for looking up users based on 3PID (#14405)Ashish Kumar2022-11-112-0/+27
|
* Merge/remove `Slaved*` stores into `WorkerStores` (#14375)Nick Mills-Barrett2022-11-1115-374/+198
|
* Remove duplicated code to evict entries. (#14410)Patrick Cloke2022-11-101-9/+2
| | | | | | | | This code was factored out to a method, but also left in-place. Calling this twice in a row makes no sense: the first call will reduce the size appropriately, but the loop will immediately exit since the cache size was already reduced.
* Fix PostgreSQL sometimes using table scans for `event_search` (#14409)Sean Quah2022-11-101-0/+33
| | | | | | | | | | | PostgreSQL may underestimate the number of distinct `room_id`s in `event_search`, which can cause it to use table scans for queries for multiple rooms. Fix this by setting `n_distinct` on the column. Resolves #14402. Signed-off-by: Sean Quah <seanq@matrix.org>
* Quieter logging for stateres failure at missing prev events (#14346)David Robertson2022-11-101-3/+2
|
* Drop support for Postgres 10 in full text search code. (#14397)Patrick Cloke2022-11-092-43/+23
|
* Remove support for PostgreSQL 10 (#14392)Sean Quah2022-11-081-2/+2
| | | Signed-off-by: Sean Quah <seanq@matrix.org>
* Correctly create power level event during initial room creation (#14361)Shay2022-11-071-2/+23
|
* Fix background update table-scanning `events` (#14374)Richard van der Hoff2022-11-071-8/+8
| | | | | When this background update did its last batch, it would try to update all the events that had been inserted since the bgupdate started, which could cause a table-scan. Make sure we limit the update correctly.
* Do not reject `/sync` requests with unrecognised filter fields (#14369)Sean Quah2022-11-071-4/+4
| | | | | | | | For forward compatibility, Synapse needs to ignore fields it does not recognise instead of raising an error. Fixes #14365. Signed-off-by: Sean Quah <seanq@matrix.org>
* Bump flake8-bugbear from 22.9.23 to 22.10.27 (#14329)dependabot[bot]2022-11-043-4/+6
| | | | | Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com> Co-authored-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Fix /refresh endpoint version (#14364)Tulir Asokan2022-11-041-1/+1
|
* Merge tag 'v1.71.0rc2' into developSean Quah2022-11-041-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Synapse 1.71.0rc2 (2022-11-04) ============================== Please note that, as announced in the release notes for Synapse 1.69.0, legacy Prometheus metric names are now disabled by default. They will be removed altogether in Synapse 1.73.0. If not already done, server administrators should update their dashboards and alerting rules to avoid using the deprecated metric names. See the [upgrade notes](https://matrix-org.github.io/synapse/v1.71/upgrade.html#upgrading-to-v1710) for more details. Improved Documentation ---------------------- - Document the changes to monthly active user metrics due to deprecation of legacy Prometheus metric names. ([\#14358](https://github.com/matrix-org/synapse/issues/14358), [\#14360](https://github.com/matrix-org/synapse/issues/14360)) Deprecations and Removals ------------------------- - Disable legacy Prometheus metric names by default. They can still be re-enabled for now, but they will be removed altogether in Synapse 1.73.0. ([\#14353](https://github.com/matrix-org/synapse/issues/14353)) Internal Changes ---------------- - Run unit tests against Python 3.11. ([\#13812](https://github.com/matrix-org/synapse/issues/13812))
| * Disable legacy Prometheus metric names by default. They can still be ↵reivilibre2022-11-021-1/+1
| | | | | | | | re-enabled for now, but they will be removed altogether in Synapse 1.73.0. (#14353)
* | Implement MSC3912: Relation-based redactions (#14260)Brendan Abolivier2022-11-037-24/+179
| | | | | | Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* | Fix typo in #13320 which could cause log spam (#14347)David Robertson2022-11-011-1/+1
| |
* | Allow PUT/GET of aliases during faster join (#14292)David Robertson2022-11-011-2/+2
|/ | | without blocking on full state.
* Revert "Fix event size checks (#13710)"David Robertson2022-11-011-5/+5
| | | | | | | | | | | This reverts commit fab495a9e1442d99e922367f65f41de5eaa488eb. As noted in https://github.com/matrix-org/synapse/pull/13710#issuecomment-1298396007: > We want to see this change land for the protocol's sake (and plan to un-revert it) but want to give this a little more time before releasing this.
* Fix type annotation causing import time error in the Complement forking ↵reivilibre2022-11-011-2/+2
| | | | | launcher. (#14084) Co-authored-by: David Robertson <davidr@element.io>
* Fix dehydrated device REST checks (#14336)David Robertson2022-10-311-3/+2
|
* Support OIDC backchannel logouts (#11414)Quentin Gliech2022-10-316-36/+488
| | | | | | | If configured an OIDC IdP can log a user's session out of Synapse when they log out of the identity provider. The IdP sends a request directly to Synapse (and must be configured with an endpoint) when a user logs out.
* Avoid incrementing bg process utime/stime counters by negative durations ↵David Robertson2022-10-311-2/+4
| | | | (#14323)
* Prevent federation user keys query from returning device names if disallowed ↵Andrew Morgan2022-10-282-9/+45
| | | | (#14304)
* Improve `RawHeaders` type hints (#14303)David Robertson2022-10-282-9/+23
|
* Switch search SQL to triple-quote strings. (#14311)Patrick Cloke2022-10-281-89/+99
| | | | For ease of reading we switch from concatenated strings to triple quote strings.
* Merge branch 'master' into developOlivier Wilkinson (reivilibre)2022-10-283-11/+25
|\
| * Fix room creation being rate limited too aggressively since Synapse v1.69.0. ↵reivilibre2022-10-282-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#14314) * Introduce a test for the old behaviour which we want to restore * Reintroduce the old behaviour in a simpler way * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Use 1 credit instead of 2 for creating a room: be more lenient than before Notably, the UI in Element Web was still broken after restoring to prior behaviour. After discussion, we agreed that it would be sensible to increase the limit. Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
| * Fix incorrectly sending authentication tokens to application service as ↵David Robertson2022-10-261-5/+7
| | | | | | | | headers (#14301)
* | Check appservice user interest against the local users instead of all users ↵Eric Eastwood2022-10-273-4/+32
| | | | | | | | (`get_users_in_room` mis-use) (#13958)
* | Fix tests for change in PostgreSQL 14 behavior change. (#14310)Patrick Cloke2022-10-271-3/+2
| | | | | | | | | | | | | | PostgreSQL 14 changed the behavior of `websearch_to_tsquery` to improve some behaviour. The tests were hitting those edge-cases about handling of hanging double quotes. This fixes the tests to take into account the PostgreSQL version.
* | Add workers settings to configuration manual (#14086)Dirk Klimpel2022-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add workers settings to configuration manual * Update `pusher_instances` * update url to python logger * update headlines * update links after headline change * remove link from `daemon process` There is no docs in Synapse for this * extend example for `federation_sender_instances` and `pusher_instances` * more infos about stream writers * add link to DAG * update `pusher_instances` * update `worker_listeners` * update `stream_writers` * Update `worker_name` Co-authored-by: David Robertson <davidr@element.io>
* | Fix presence bug introduced in 1.64 by #13313 (#14243)Mathieu Velten2022-10-271-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | * Fix presence bug introduced in 1.64 by #13313 Signed-off-by: Mathieu Velten <mathieuv@matrix.org> * Add changelog * Add DISTINCT * Apply suggestions from code review Signed-off-by: Mathieu Velten <mathieuv@matrix.org>