77 Commits

Author SHA1 Message Date
nisbet-hubbard
cef9361c6c
Use 0222 2023-12-09 13:50:59 +08:00
nisbet-hubbard
6f99876d0e
Clean-up 2023-12-09 13:01:46 +08:00
nisbet-hubbard
c63e69d040
Update comment 2023-12-09 11:44:13 +08:00
nisbet-hubbard
5777edbcad
Fix unix socket permissions 2023-12-09 11:31:08 +08:00
Boris Rybalkin
bf477c13fc fix one more IsUnixSocket check 2023-11-17 12:25:49 +00:00
Boris Rybalkin
06fcbb12ae chmod comment 2023-11-17 12:19:28 +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
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
a397b72c30
Make HTTP timeout configurable 2023-09-19 11:48:49 +02: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
Till Faelligen
8baa252aa1
Add temporary prometheus metrics for snapshot size 2023-09-07 10:02:50 +02:00
David Robertson
ebbf23cf7d
Remove duration suffices 2023-08-31 12:04:59 +01:00
David Robertson
545f80673c
Log setup and processing times for requests
Closes #277.
2023-08-31 11:49:49 +01:00
Till Faelligen
182e010e67
Make JSONB migration happy 2023-08-02 16:38:56 +02:00
Till Faelligen
7b3ef7ee28
Migrate data to JSONB, update device data query 2023-08-02 14:00:42 +02:00
Till Faelligen
a085e1fc04
Merge branch 'main' of github.com:matrix-org/sliding-sync into s7evink/devicedata 2023-08-02 11:07:40 +02:00
David Robertson
9248d4e512
Review comments 2023-07-28 18:38:19 +01:00
Till Faelligen
9b7d27dd87
Add initial support for database migrations 2023-07-28 15:10:15 +02:00
David Robertson
5904e5a3c7
Make transaction id delay time configurable 2023-07-26 12:23:38 +01:00
Kegan Dougal
c47665f1e8 Actually honour max conns globally, not per storage struct 2023-07-12 17:36:59 +01:00
kegsay
b72ad3bded
Merge branch 'main' into dmr/debug-from-stable 2023-07-12 03:41:06 -07:00
Kegan Dougal
f36c038cf8 Rate limit pubsub.V2DeviceData updates to be at most 1 per second
The db writes are still instant, but the notifications are now delayed
by up to 1 second, in order to not swamp the pubsub channels.
2023-06-26 21:04:02 -07:00
Kegan Dougal
4156b085f6 comments 2023-06-19 18:23:00 +01:00
Kegan Dougal
4c661fbdd1 Add db conns test; uncomment DBMaxConns to break the world 2023-06-19 15:56:22 +01:00
Kegan Dougal
eefbe334b4 Unbreak build 2023-06-15 12:05:37 +01:00
Kegan Dougal
08f34ba5c2 Move out SetCallbacks to allow for better DI 2023-06-08 16:59:37 +01:00
networkException
4b7754f7d1
Allow setting a log level using environment variables
Signed-off-by: networkException <git@nwex.de>
2023-05-09 20:39:11 +02:00
David Robertson
601e3fce49
More sentry logging 2023-04-13 15:02:46 +01:00
David Robertson
c4cc35fcfc
Also cover Fatal and Panic logging 2023-04-05 18:39:51 +01:00
David Robertson
c76c04128e
require tlsCert and tlsKey to be nonempty
Co-authored-by: kegsay <kegsay@gmail.com>
2023-03-29 12:17:26 +01:00
Joe Groocock
d066dce13c
Implement listening on TLS/HTTPS
This uses Go's vanilla ListenAndServeTLS(), and as such none of the
normal TLS toggles are available for the user to configure. This
provides a basic H2+TLS1.3 with modern cipher experience, which should
be good enough for use on the open internet.

Signed-off-by: Joe Groocock <me@frebib.net>
2023-03-23 22:15:23 +00:00
Kegan Dougal
5de7fa72f6 Read TraceContext headers to get full client/server spans 2023-02-21 10:50:39 +00:00
Kegan Dougal
2139eda047 tests: add test for full connection buffers and expiry
Fixed a bug in notification code which could cause integration
tests to not be as deterministic as intended; should fix flakey
tests.
2023-02-03 10:00:45 +00:00
Kegan Dougal
aa28df161c Rename package -> github.com/matrix-org/sliding-sync 2022-12-15 11:08:50 +00:00
Kegan Dougal
be8543a21a add extensions for typing and receipts; bugfixes and additional perf improvements
Features:
 - Add `typing` extension.
 - Add `receipts` extension.
 - Add comprehensive prometheus `/metrics` activated via `SYNCV3_PROM`.
 - Add `SYNCV3_PPROF` support.
 - Add `by_notification_level` sort order.
 - Add `include_old_rooms` support.
 - Add support for `$ME` and `$LAZY`.
 - Add correct filtering when `*,*` is used as `required_state`.
 - Add `num_live` to each room response to indicate how many timeline entries are live.

Bug fixes:
 - Use a stricter comparison function on ranges: fixes an issue whereby UTs fail on go1.19 due to change in sorting algorithm.
 - Send back an `errcode` on HTTP errors (e.g expired sessions).
 - Remove `unsigned.txn_id` on insertion into the DB. Otherwise other users would see other users txn IDs :(
 - Improve range delta algorithm: previously it didn't handle cases like `[0,20] -> [20,30]` and would panic.
 - Send HTTP 400 for invalid range requests.
 - Don't publish no-op unread counts which just adds extra noise.
 - Fix leaking DB connections which could eventually consume all available connections.
 - Ensure we always unblock WaitUntilInitialSync even on invalid access tokens. Other code relies on WaitUntilInitialSync() actually returning at _some_ point e.g on startup we have N workers which bound the number of concurrent pollers made at any one time, we need to not just hog a worker forever.

Improvements:
 - Greatly improve startup times of sync3 handlers by improving `JoinedRoomsTracker`: a modest amount of data would take ~28s to create the handler, now it takes 4s.
 - Massively improve initial initial v3 sync times, by refactoring `JoinedRoomsTracker`, from ~47s to <1s.
 - Add `SlidingSyncUntil...` in tests to reduce races.
 - Tweak the API shape of JoinedUsersForRoom to reduce state block processing time for large rooms from 63s to 39s.
 - Add trace task for initial syncs.
 - Include the proxy version in UA strings.
 - HTTP errors now wait 1s before returning to stop clients tight-looping on error.
 - Pending event buffer is now 2000.
 - Index the room ID first to cull the most events when returning timeline entries. Speeds up `SelectLatestEventsBetween` by a factor of 8.
 - Remove cancelled `m.room_key_requests` from the to-device inbox. Cuts down the amount of events in the inbox by ~94% for very large (20k+) inboxes, ~50% for moderate sized (200 events) inboxes. Adds book-keeping to remember the unacked to-device position for each client.
2022-12-14 18:53:55 +00:00
Kegan Dougal
a37aee4c2b Improve logging; remove useless fields 2022-08-16 14:23:05 +01:00
Kegan Dougal
47b74a6be6 Automatically start v2 pollers on startup
We can do this now because we store the access token for each device.

Throttled at 16 concurrent sync requests to avoid causing
thundering herds on startup.
2022-07-14 10:48:45 +01:00
Kegan Dougal
8a677347f8 server/bugfix: fix panic on invited rooms; expose v2 server url to client
- Expose `/client/server.json` so clients know the CS API base endpoint for things like media requests
  (and in future sending events, etc)
- Tidy up a few comments.
2022-02-24 14:14:59 +00:00
Kegan Dougal
63ef76f0ca add unstable prefix 2021-12-22 18:20:02 +00:00
Kegan Dougal
617165e59f Bind to /_matrix/client/org.matrix.msc3575/sync as well as /_matrix/client/v3/sync 2021-12-22 16:23:57 +00:00
Kegan Dougal
d8bc5b3aa7 Support CORS on /sync 2021-11-24 16:27:33 +00:00
Kegan Dougal
415575d942 Flesh out client, fix session management
- Request first 100 rooms, with placeholder icons
- Add a `http.FileServer` for everything under `/client` for images.
- Sessions are only 400d if they provide a `?pos=` with the session ID.
2021-09-28 13:48:42 +01:00
Kegan Dougal
992208f3e8 Add client.html with it interacting with the synclive API
Very rough WIP, need to verify a lot more to check correctness
2021-09-24 14:30:00 +01:00
Kegan Dougal
80a07e5c1d Factor out handler errors 2021-09-20 17:21:02 +01:00
Kegan Dougal
e26ec22875 Move sync3 API into a new package 2021-09-20 16:52:50 +01:00
Kegan Dougal
74a591d913 Refactor server to put events in events and event IDs elsewhere
No LRU cache yet
2021-09-09 15:49:22 +01:00
Kegan Dougal
35ce28bb96 Add room_list API stubs 2021-08-11 14:37:52 +01:00
Kegan Dougal
9266a3a834 More bugfixes and tests
Specifically, /sync requests with the "latest" sync token should not
block for paginated requests.
2021-08-10 14:54:29 +01:00
Kegan Dougal
3acec84f21 Initial test for room_member stream 2021-08-06 16:29:25 +01:00
Kegan Dougal
8b920df816 Track joined members in-memory for use with the notifier 2021-08-05 17:57:40 +01:00