summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--synapse/app/pusher.py6
-rw-r--r--synapse/app/synchrotron.py6
-rw-r--r--synapse/config/workers.py14
-rw-r--r--synapse/server.py3
-rw-r--r--synapse/storage/_base.py2
5 files changed, 10 insertions, 21 deletions
diff --git a/synapse/app/pusher.py b/synapse/app/pusher.py
index a26a3bd394..5d4db4f892 100644
--- a/synapse/app/pusher.py
+++ b/synapse/app/pusher.py
@@ -18,7 +18,6 @@ import synapse
 
 from synapse.server import HomeServer
 from synapse.config._base import ConfigError
-from synapse.config.workers import clobber_with_worker_config
 from synapse.config.logger import setup_logging
 from synapse.config.homeserver import HomeServerConfig
 from synapse.http.site import SynapseSite
@@ -241,6 +240,9 @@ class PusherServer(HomeServer):
                 logger.exception("Error replicating from %r", replication_url)
                 yield sleep(30)
 
+    def get_event_cache_size(self):
+        return self.worker_config.event_cache_size
+
 
 def setup(worker_name, config_options):
     try:
@@ -255,8 +257,6 @@ def setup(worker_name, config_options):
 
     setup_logging(worker_config.log_config, worker_config.log_file)
 
-    clobber_with_worker_config(config, worker_config)
-
     if config.start_pushers:
         sys.stderr.write(
             "\nThe pushers must be disabled in the main synapse process"
diff --git a/synapse/app/synchrotron.py b/synapse/app/synchrotron.py
index 4443c73e6a..d10bb2b3f0 100644
--- a/synapse/app/synchrotron.py
+++ b/synapse/app/synchrotron.py
@@ -20,7 +20,6 @@ from synapse.api.constants import EventTypes, PresenceState
 from synapse.config._base import ConfigError
 from synapse.config.homeserver import HomeServerConfig
 from synapse.config.logger import setup_logging
-from synapse.config.workers import clobber_with_worker_config
 from synapse.events import FrozenEvent
 from synapse.handlers.presence import PresenceHandler
 from synapse.http.site import SynapseSite
@@ -404,6 +403,9 @@ class SynchrotronServer(HomeServer):
     def build_typing_handler(self):
         return SynchrotronTyping(self)
 
+    def get_event_cache_size(self):
+        return self.worker_config.event_cache_size
+
 
 def start(worker_name, config_options):
     try:
@@ -418,8 +420,6 @@ def start(worker_name, config_options):
 
     setup_logging(worker_config.log_config, worker_config.log_file)
 
-    clobber_with_worker_config(config, worker_config)
-
     database_engine = create_engine(config.database_config)
 
     ss = SynchrotronServer(
diff --git a/synapse/config/workers.py b/synapse/config/workers.py
index f2c77ef59a..503358e03e 100644
--- a/synapse/config/workers.py
+++ b/synapse/config/workers.py
@@ -33,20 +33,6 @@ Worker = collections.namedtuple("Worker", [
 ])
 
 
-def clobber_with_worker_config(config, worker_config):
-    """Overrides some of the keys of the main config with worker-specific
-    values. We only need to override the keys that are accessed deep
-    withing synapse code. Most of the keys that we want to override in
-    the workers are accessed in setup code that is rewritten specifically
-    for the workers. In that new code we can access the worker config directly,
-    so we don't need to override the values in the main config."""
-
-    # TODO: The event_cache_size is accessed in the db setup. It should be
-    # possible to rejigg that code so that the cache size is pulled from the
-    # worker config directly.
-    config.event_cache_size = worker_config.event_cache_size
-
-
 def read_worker_config(config):
     return Worker(
         app=config["app"],
diff --git a/synapse/server.py b/synapse/server.py
index dd4b81c658..b3c31ece73 100644
--- a/synapse/server.py
+++ b/synapse/server.py
@@ -236,6 +236,9 @@ class HomeServer(object):
     def remove_pusher(self, app_id, push_key, user_id):
         return self.get_pusherpool().remove_pusher(app_id, push_key, user_id)
 
+    def get_event_cache_size(self):
+        return self.config.event_cache_size
+
 
 def _make_dependency_method(depname):
     def _get(hs):
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 32c6677d47..2932880cc5 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -166,7 +166,7 @@ class SQLBaseStore(object):
         self._get_event_counters = PerformanceCounters()
 
         self._get_event_cache = Cache("*getEvent*", keylen=3, lru=True,
-                                      max_entries=hs.config.event_cache_size)
+                                      max_entries=hs.get_event_cache_size())
 
         self._state_group_cache = DictionaryCache(
             "*stateGroupCache*", 2000 * CACHE_SIZE_FACTOR