273 Commits

Author SHA1 Message Date
Guillem Nieto Taló
45f3e012db fix: urlencode since opaque string
Since/next batch is an opaque string and might need to be urlencoded
before being sent to the server.

Signed-off-by: Guillem Nieto <gnieto.talo@gmail.com>
2024-05-20 12:09:31 +02:00
Kegan Dougal
fdbebaea68 Some review comments; swap to UPDATE..RETURNING 2024-05-20 08:22:48 +01:00
Kegan Dougal
b383ed0d82 Add migrations and refactor internal structs 2024-05-17 13:45:14 +01:00
Kegan Dougal
9620a624d7 Comment on escaped dots 2024-04-26 12:16:39 +01:00
Kegan Dougal
0af85096aa Check for unstable prefix in MSC4115 2024-04-25 15:15:42 +01:00
Kegan Dougal
c4f2617a2d Remove MSC4115 unsigned.membership field
With integration tests. This is required because this field
is scoped per-v2-user, but because the proxy deduplicates events
it means we might see the membership value for a different user.
We can't set this field correctly as we lack that information, so
rather than lie to clients instead just delete the field.

Fixes https://github.com/matrix-org/sliding-sync/issues/421
2024-04-24 16:20:07 +01:00
Kegan Dougal
05a82a43dc Same race pattern as timeSince for timeSleep 2024-03-11 12:06:13 +00:00
Kegan Dougal
905f815794 bugfix: ensure sentry username/id values are correct
Previously there were wrong under high concurrency due to
using the global hub instead of a per-request hub.
2024-03-05 11:30:05 +00:00
Kegan Dougal
eae54fbcb7 bugfix: send [] initially when the poller starts up
This ensures we tell clients about used/missing fallback keys initially.
2024-01-05 11:20:33 +00:00
Kegan Dougal
0bd026fc09 bugfix: correctly tell clients when the fallback key has been used
Fixes a class of unable to decrypt errors caused when the fallback
key was used but the client was unaware.
2024-01-04 17:06:28 +00:00
Boris Rybalkin
8d38785ac0 back to util functions 2023-11-16 19:31:43 +00:00
Boris Rybalkin
b055d27d22 extract HomeServerUrl struct 2023-11-16 13:57:51 +00:00
Boris Rybalkin
ae73ace4a4 unix socket support
Signed-off-by: Boris Rybalkin <ribalkin@gmail.com>
2023-11-16 11:02:53 +00:00
David Robertson
a8bef7ecd5
Fix bad merge between #363 and #368 2023-11-10 11:44:55 +00:00
David Robertson
cbd3c3c5c0
Merge pull request #363 from matrix-org/dmr/resnapshot-3 2023-11-10 11:38:12 +00:00
Kegan Dougal
be0fb09ed9 Review comments 2023-11-08 15:05:43 +00:00
Kegan Dougal
c868e540db bugfix: handle malformed state/timeline responses
Specifically, look for the create event in the timeline as this
has been seen in the wild on Synapse. Fixes #367.
2023-11-08 10:36:36 +00:00
David Robertson
c239cacc83
Initialise: handle gappy polls and ditch prependStateEvents 2023-11-03 15:42:25 +00:00
David Robertson
f595aed2c5
Add a separate payload for redacting state
So that we don't end up nuking conns unnecessarily.
2023-11-01 19:03:17 +00:00
Kegan Dougal
32c2f6b93d Actually use the provided value 2023-10-11 13:21:52 +01:00
Kegan Dougal
97d53448d7 Fix poller race condition 2023-10-11 12:58:05 +01:00
Kegan Dougal
d65c4ebdcf Fix race condition in test 2023-10-11 12:36:21 +01:00
Kegan Dougal
0856a8d53d bugfix: give up polling if the /sync response keeps erroring for >50min 2023-10-03 13:02:17 +01:00
kegsay
477cf8bd6c
Merge pull request #312 from matrix-org/s7evink/fix-poller-startup-metrics
Update the poller metrics after a poller was started
2023-09-28 10:57:13 +01:00
David Robertson
a28e419d5d
Update mockClient to match new interface 2023-09-26 13:35:24 +01:00
David Robertson
7111ab1d9f
Check that the homeserver is reachable at startup
Closes #286.

Tested as follows (see line 4):

```
Sync v3 [0.99.10] (6fe9b18)
Debug=true LogLevel= MaxConns=0
Starting prometheus listener on :6060
13:23:33 WRN Could not contact upstream homeserver. Is SYNCV3_SERVER set correctly? error="Get \"http://localhost:8888/_matrix/client/versions\": dial tcp [::1]:8888: connect: connection refused" dest=http://localhost:8888
2023/09/26 13:23:33 OK   20230728114555_device_data_drop_id.sql (7.48ms)
2023/09/26 13:23:33 OK   20230802121023_device_data_jsonb.go (13.85ms)
2023/09/26 13:23:33 OK   20230814183302_cbor_device_data.go (9.01ms)
2023/09/26 13:23:33 OK   20230822180807_bogus_snapshot_cleanup.go (7.64ms)
2023/09/26 13:23:33 OK   20230913120537_events_missing_previous.sql (7.15ms)
2023/09/26 13:23:33 goose: successfully migrated database to version: 20230913120537
13:23:33 INF creating handler
13:23:33 INF retrieved global snapshot from database
13:23:33 INF listening on 0.0.0.0:8844
13:23:33 INF StartV2Pollers num_devices=0 num_fail_decrypt=0
13:23:33 INF StartV2Pollers finished
```
2023-09-26 13:24:26 +01:00
Till Faelligen
06b6bbedf3
Move to else, as we otherwise count failed pollers as well 2023-09-22 09:44:52 +02:00
Till Faelligen
0c149ba78d
Update the poller metrics after the poller was started 2023-09-22 09:41:48 +02:00
Kegan Dougal
4114118a9e Reduce mutex contention on callbacks 2023-09-21 17:15:23 +01:00
David Robertson
e75a462d4c
Merge pull request #300 from matrix-org/dmr/invalidate-timelines 2023-09-20 14:29:55 +01:00
kegsay
bf9e90127f
Merge pull request #299 from matrix-org/kegan/poll-retry-loop-bad-create-event
bugfix: don't wedge pollers when they get bad state blocks
2023-09-20 11:51:24 +01:00
Till Faelligen
317a722286
Merge branch 'main' of github.com:matrix-org/sliding-sync into s7evink/httptimeout 2023-09-19 15:03:35 +02:00
kegsay
94a4789287
Merge branch 'main' into kegan/poll-retry-loop-bad-create-event 2023-09-19 13:48:40 +01:00
Kegan Dougal
84c976e8e8 Additional tests; linting 2023-09-19 13:47:58 +01:00
David Robertson
d3ba1f1c30
Move TimelineResponse back to sync2 2023-09-19 12:41:25 +01:00
David Robertson
d9ecbbb412
Merge remote-tracking branch 'origin/main' into dmr/invalidate-timelines 2023-09-19 12:40:41 +01:00
David Robertson
957bdee9d2
Merge branch 'main' into dmr/invalidate-timelines 2023-09-19 12:40:13 +01:00
David Robertson
80ed88fe89
Remove per-device token migration added in #89
This is causing cyclic import pain. Remove it, rather than port it to
the newer migration infrastructure.

This means that users must run the migration before upgrading to the
any version which includes this change.
2023-09-19 11:32:13 +01:00
Till Faelligen
f356c64e25
Use "NewHTTPClient" 2023-09-19 11:50:34 +02:00
Till Faelligen
a397b72c30
Make HTTP timeout configurable 2023-09-19 11:48:49 +02:00
David Robertson
5b32cc44c2
Merge pull request #296 from matrix-org/dmr/cache-invalidation 2023-09-14 11:08:44 +01:00
Kegan Dougal
e4cedaabcd Merge branch 'main' into kegan/poll-retry-loop-bad-create-event 2023-09-14 09:29:44 +01:00
David Robertson
df01e50438
Pass TimelineResponse struct around 2023-09-13 19:17:53 +01:00
Quentin Gliech
af5e8579b2 Better propagate request context
This properly propagates the go Context on down to all HTTP calls, which means that outgoing request have the OTLP trace context.
This also adds the Jaeger propagator to the list of OTEL propagators, so that Synapse properly gets the incoming trace context.
It also upgrades all the OTEL libraries
2023-09-13 19:41:52 +02:00
David Robertson
0d4e8c6df9
Remove debug and improve comments 2023-09-12 16:25:10 +01:00
Kegan Dougal
7c80b5424a Prioritise retriable errors over unretriable errors
Bump to Go 1.20 for errors.Join and added introspection to
errors.As to inspect []error.
2023-09-12 14:57:40 +01:00
Kegan Dougal
471bb8c898 bugfix: don't wedge pollers when they get bad state blocks
We returned an error in Initialise when there is no create event
in the state block. If this happens, the poller automatically retries
the same request, tightlooping as the data is always going to cause
the same error. Instead, return an `internal.DataError` which is a way
of expressly telling the pollers to continue and advance the since token.

With regression test.

NB: This regression test also caught a potential bug which this PR could
have introduced. This PR lets the since token skip over bad responses, but
we want to make damn sure we process EVERYTHING ELSE in that response. In
particular, we could have skipped over large sections of `parseRoomsResponse`
as we would bail early on errors. This is now fixed to bail only after processing
the entire joined rooms map.
2023-09-12 14:16:21 +01:00
David Robertson
afe589921e
Invalidation: don't bother propagating a snapshot 2023-09-08 18:17:13 +01:00
David Robertson
f4555f3c22
Emit Invalidation payloads 2023-09-07 20:41:11 +01:00
David Robertson
777cb357fe
Factor out AccumulateResult struct 2023-09-07 20:41:11 +01:00