From bc8fa1509d3885d111a2ef98e12e9ce66a19a3a8 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 19 Feb 2019 11:24:59 +0000 Subject: Documentation --- docs/tcp_replication.rst | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'docs/tcp_replication.rst') diff --git a/docs/tcp_replication.rst b/docs/tcp_replication.rst index 62225ba6f4..852f1113a3 100644 --- a/docs/tcp_replication.rst +++ b/docs/tcp_replication.rst @@ -137,7 +137,6 @@ for each stream so that on reconneciton it can start streaming from the correct place. Note: not all RDATA have valid tokens due to batching. See ``RdataCommand`` for more details. - Example ~~~~~~~ @@ -221,3 +220,23 @@ SYNC (S, C) See ``synapse/replication/tcp/commands.py`` for a detailed description and the format of each command. + + +Cache Invalidation Stream +~~~~~~~~~~~~~~~~~~~~~~~~~ + +The cache invalidation stream is used to inform workers when they need to +invalidate any of their caches in the data store. This is done by streaming all +cache invalidations done on master down to the workers, assuming that any caches +on the workers also exist on the master. + +Each individual cache invalidation results in a row being sent down replication, +which includes the cache name (the name of the function) and they key to +invalidate. For example:: + + > RDATA caches 550953771 ["get_user_by_id", ["@bob:example.com"], 1550574873251] + +However, there are times when a number of caches need to be invalidated at the +same time with the same key. To reduce traffic we batch those invalidations into +a single poke by defining a special cache name that workers understand to mean +to expand to invalidate the correct caches. -- cgit 1.4.1 From 62175a20e51b4ce71b9e7a18755a42e259bd2ff8 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 19 Feb 2019 11:38:40 +0000 Subject: Docs --- docs/tcp_replication.rst | 5 +++++ synapse/storage/_base.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'docs/tcp_replication.rst') diff --git a/docs/tcp_replication.rst b/docs/tcp_replication.rst index 852f1113a3..73436cea62 100644 --- a/docs/tcp_replication.rst +++ b/docs/tcp_replication.rst @@ -240,3 +240,8 @@ However, there are times when a number of caches need to be invalidated at the same time with the same key. To reduce traffic we batch those invalidations into a single poke by defining a special cache name that workers understand to mean to expand to invalidate the correct caches. + +Currently the special cache names are declared in ``synapse/storage/_base.py`` +and are: + +1. ``cs_cache_fake`` ─ invalidates caches that depend on the current state diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index 9db594bc42..f1a5366b95 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -1201,7 +1201,7 @@ class SQLBaseStore(object): Args: txn room_id (str): Room where state changed - members_changed (Iterable[str]): The user_ids of members that have changed + members_changed (iterable[str]): The user_ids of members that have changed """ txn.call_after(self._invalidate_state_caches, room_id, members_changed) @@ -1216,7 +1216,8 @@ class SQLBaseStore(object): Args: room_id (str): Room where state changed - members_changed (set[str]): The user_ids of members that have changed + members_changed (iterable[str]): The user_ids of members that have + changed """ for member in members_changed: self.get_rooms_for_user_with_stream_ordering.invalidate((member,)) -- cgit 1.4.1