summary refs log tree commit diff
path: root/synapse/replication/tcp/protocol.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix logging context warnings when losing replication connection (#10984)Sean Quah2021-10-151-5/+13
| | | | | | Instead of triggering `__exit__` manually on the replication handler's logging context, use it as a context manager so that there is an `__enter__` call to balance the `__exit__`.
* Use inline type hints in various other places (in `synapse/`) (#10380)Jonathan de Jong2021-07-151-7/+7
|
* Remove `synapse.types.Collection` (#9856)Richard van der Hoff2021-04-221-2/+1
| | | This is no longer required, since we have dropped support for Python 3.5.
* Merge branch 'master' into developAndrew Morgan2021-04-211-1/+1
|\
| * Stop BackgroundProcessLoggingContext making new prometheus timeseries (#9854)Richard van der Hoff2021-04-211-1/+1
| | | | | | | | This undoes part of b076bc276e881b262048307b6a226061d96c4a8d.
* | Merge branch 'master' into developAndrew Morgan2021-04-201-1/+1
|\|
| * Always use the name as the log ID. (#9829)Patrick Cloke2021-04-201-1/+1
| | | | | | | | | | As far as I can tell our logging contexts are meant to log the request ID, or sometimes the request ID followed by a suffix (this is generally stored in the name field of LoggingContext). There's also code to log the name@memory location, but I'm not sure this is ever used. This simplifies the code paths to require every logging context to have a name and use that in logging. For sub-contexts (created via nested_logging_contexts, defer_to_threadpool, Measure) we use the current context's str (which becomes their name or the string "sentinel") and then potentially modify that (e.g. add a suffix).
* | Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
|/ | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Record more information into structured logs. (#9654)Patrick Cloke2021-04-081-2/+3
| | | | Records additional request information into the structured logs, e.g. the requester, IP address, etc.
* Make it possible to use dmypy (#9692)Erik Johnston2021-03-261-1/+1
| | | | | | | | | Running `dmypy run` will do a `mypy` check while spinning up a daemon that makes rerunning `dmypy run` a lot faster. `dmypy` doesn't support `follow_imports = silent` and has `local_partial_types` enabled, so this PR enables those options and fixes the issues that were newly raised. Note that `local_partial_types` will be enabled by default in upcoming mypy releases.
* Fix remaining mypy issues due to Twisted upgrade. (#9608)Patrick Cloke2021-03-151-0/+9
|
* Fix additional type hints from Twisted 21.2.0. (#9591)Patrick Cloke2021-03-121-15/+9
|
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-18/+9
| | | | | | | - Update black version to the latest - Run black auto formatting over the codebase - Run autoformatting according to [`docs/code_style.md `](https://github.com/matrix-org/synapse/blob/80d6dc9783aa80886a133756028984dbf8920168/docs/code_style.md) - Update `code_style.md` docs around installing black to use the correct version
* Various clean-ups to the logging context code (#8935)Patrick Cloke2020-12-141-2/+1
|
* Enable mypy checking for unreachable code and fix instances. (#8432)Patrick Cloke2020-10-011-4/+6
|
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-1/+1
|
* Handle replication commands synchronously where possible (#7876)Richard van der Hoff2020-07-271-17/+28
| | | Most of the stuff we do for replication commands can be done synchronously. There's no point spinning up background processes if we're not going to need them.
* Track command processing as a background process (#7879)Richard van der Hoff2020-07-221-1/+18
| | | | I'm going to be doing more stuff synchronously, and I don't want to lose the CPU metrics down the sofa.
* Fix some spelling mistakes / typos. (#7811)Patrick Cloke2020-07-091-1/+1
|
* Don't relay REMOTE_SERVER_UP cmds to same conn. (#7352)Erik Johnston2020-04-291-1/+1
| | | | | | | | | | | | | | For direct TCP connections we need the master to relay REMOTE_SERVER_UP commands to the other connections so that all instances get notified about it. The old implementation just relayed to all connections, assuming that sending back to the original sender of the command was safe. This is not true for redis, where commands sent get echoed back to the sender, which was causing master to effectively infinite loop sending and then re-receiving REMOTE_SERVER_UP commands that it sent. The fix is to ensure that we only relay to *other* connections and not to the connection we received the notification from. Fixes #7334.
* Fix replication metrics when using redis (#7325)Erik Johnston2020-04-221-36/+16
|
* Add ability to run replication protocol over redis. (#7040)Erik Johnston2020-04-221-26/+12
| | | This is configured via the `redis` config options.
* Handle one-word replication commands correctlyRichard van der Hoff2020-04-071-3/+11
| | | | | `REPLICATE` is now a valid command, and it's nice if you can issue it from the console without remembering to call it `REPLICATE ` with a trailing space.
* Move server command handling out of TCP protocol (#7187)Erik Johnston2020-04-071-114/+51
| | | This completes the merging of server and client command processing.
* Move client command handling out of TCP protocol (#7185)Erik Johnston2020-04-061-166/+31
| | | The aim here is to move the command handling out of the TCP protocol classes and to also merge the client and server command handling (so that we can reuse them for redis protocol). This PR simply moves the client paths to the new `ReplicationCommandHandler`, a future PR will move the server paths too.
* Remove usage of "conn_id" for presence. (#7128)Erik Johnston2020-03-301-2/+7
| | | | | | | | | | | | | | | | * Remove `conn_id` usage for UserSyncCommand. Each tcp replication connection is assigned a "conn_id", which is used to give an ID to a remotely connected worker. In a redis world, there will no longer be a one to one mapping between connection and instance, so instead we need to replace such usages with an ID generated by the remote instances and included in the replicaiton commands. This really only effects UserSyncCommand. * Add CLEAR_USER_SYNCS command that is sent on shutdown. This should help with the case where a synchrotron gets restarted gracefully, rather than rely on 5 minute timeout.
* Move catchup of replication streams to worker. (#7024)Erik Johnston2020-03-251-135/+71
| | | This changes the replication protocol so that the server does not send down `RDATA` for rows that happened before the client connected. Instead, the server will send a `POSITION` and clients then query the database (or master out of band) to get up to date.
* Propagate cache invalidates from workers to other workers. (#6748)Erik Johnston2020-01-271-1/+1
| | | Currently if a worker invalidates a cache it will be streamed to master, which then didn't forward those to other workers.
* Wake up transaction queue when remote server comes back online (#6706)Erik Johnston2020-01-171-0/+15
| | | | | This will be used to retry outbound transactions to a remote server if we think it might have come back up.
* Port synapse.replication.tcp to async/await (#6666)Erik Johnston2020-01-161-40/+32
| | | | | | | | | | * Port synapse.replication.tcp to async/await * Newsfile * Correctly document type of on_<FOO> functions as async * Don't be overenthusiastic with the asyncing....
* Fixup synapse.replication to pass mypy checks (#6667)Erik Johnston2020-01-141-15/+21
|
* document the REPLICATE command a bit better (#6305)Richard van der Hoff2019-11-041-2/+72
| | | | since I found myself wonder how it works
* Remove usage of deprecated logger.warn method from codebase (#6271)Andrew Morgan2019-10-311-1/+1
| | | Replace every instance of `logger.warn` with `logger.warning` as the former is deprecated.
* Move logging utilities out of the side drawer of util/ and into logging/ (#5606)Amber Brown2019-07-041-1/+1
|
* Run Black. (#5482)Amber Brown2019-06-201-37/+39
|
* Make EventStream rows have a typeRichard van der Hoff2019-03-271-2/+2
| | | | ... as a precursor to combining it with the CurrentStateDelta stream.
* Add parse_row method to replication stream classRichard van der Hoff2019-03-271-1/+1
| | | | This will allow individual stream classes to override how a row is parsed.
* Fix ClientReplicationStreamProtocol.__str__ (#4929)Richard van der Hoff2019-03-251-3/+5
| | | | | | | | `__str__` depended on `self.addr`, which was absent from ClientReplicationStreamProtocol, so attempting to call str on such an object would raise an exception. We can calculate the peer addr from the transport, so there is no need for addr anyway.
* Fix bug where read-receipts lost their timestamps (#4927)Richard van der Hoff2019-03-251-8/+19
| | | | | Make sure that they are sent correctly over the replication stream. Fixes: #4898
* Simplify token replication logicAndrew Morgan2019-03-051-23/+14
|
* Clean up logic and add commentsAndrew Morgan2019-03-041-11/+18
|
* Clearer branching, fix missing list clearAndrew Morgan2019-03-041-4/+11
|
* Prevent replication wedgingAndrew Morgan2019-03-041-4/+24
|
* Merge pull request #4749 from matrix-org/erikj/replication_connection_backoffErik Johnston2019-02-271-0/+17
|\ | | | | Fix tightloop over connecting to replication server
| * Move connecting logic into ClientReplicationStreamProtocolErik Johnston2019-02-271-0/+17
| |
* | Limit cache invalidation replication line length (#4748)Erik Johnston2019-02-271-1/+16
|/
* Don't truncate command name in metricsErik Johnston2018-10-291-2/+2
|
* Remove conn_idErik Johnston2018-09-041-2/+2
|
* Remove conn_id from repl prometheus metricsErik Johnston2018-09-031-10/+10
| | | | | `conn_id` gets set to a random string, and so we end up filling up prometheus with tonnes of data series, which is bad.
* Logcontexts for replication command handlersRichard van der Hoff2018-08-171-13/+29
| | | | | | | | | | Run the handlers for replication commands as background processes. This should improve the visibility in our metrics, and reduce the number of "running db transaction from sentinel context" warnings. Ideally it means converting the things that fire off deferreds into the night into things that actually return a Deferred when they are done. I've made a bit of a stab at this, but it will probably be leaky.
* run isortAmber Brown2018-07-091-16/+24
|
* Fix tcp protocol metrics naming (#3410)Amber Brown2018-06-211-18/+35
|
* Fix replication metricsRichard van der Hoff2018-06-041-2/+2
| | | | fix bug introduced in #3256
* Merge remote-tracking branch 'origin/develop' into 3218-official-promAmber Brown2018-05-281-7/+7
|\
| * replace some iteritems with sixAdrian Tschira2018-05-191-4/+5
| | | | | | | | Signed-off-by: Adrian Tschira <nota@notafile.com>
* | more cleanupAmber Brown2018-05-221-3/+6
| |
* | fix the test failuresAmber Brown2018-05-221-1/+1
| |
* | replacing portionsAmber Brown2018-05-211-54/+34
|/
* make imports localAdrian Tschira2018-04-281-2/+2
| | | | Signed-off-by: Adrian Tschira <nota@notafile.com>
* Metrics for number of RDATA commands receivedRichard van der Hoff2018-01-151-5/+14
| | | | I found myself wishing we had this.
* Reduce log levels in tcp replicationErik Johnston2017-07-111-2/+2
|
* Make workers report to master for user ip updatesErik Johnston2017-06-271-0/+6
|
* TypoErik Johnston2017-04-101-1/+1
|
* Up replication ping timeoutErik Johnston2017-04-101-2/+4
|
* Add log linesErik Johnston2017-04-051-1/+2
|
* Rearrange metricsErik Johnston2017-04-051-16/+31
|
* Fix typoErik Johnston2017-04-051-2/+2
|
* Fixup some metrics for tcp replErik Johnston2017-04-051-0/+16
|
* Merge pull request #2098 from matrix-org/erikj/repl_tcp_fixErik Johnston2017-04-041-5/+7
|\ | | | | Advance replication streams even if nothing is listening
| * Advance replication streams even if nothing is listeningErik Johnston2017-04-041-5/+7
| | | | | | | | | | | | Otherwise the streams don't advance and steadily fall behind, so when a worker does connect either a) they'll be streamed lots of old updates or b) the connection will fail as the streams are too far behind.
* | Fiddle tcp replication loggingErik Johnston2017-04-041-2/+2
|/
* Add a timestamp to USER_SYNC commandErik Johnston2017-03-311-2/+5
| | | | This timestamp is used to indicate when the user last sync'd
* Initial TCP protocol implementationErik Johnston2017-03-301-0/+601
This defines the low level TCP replication protocol