summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2018-08-17 12:42:59 +0000
committerGitHub <noreply@github.com>2018-08-17 12:42:59 +0000
commita2d872e7b3770c454569d838bf1bb92115d9f32a (patch)
tree34c1b42c256987be5e0b56139a3da75d1f69ae8c /synapse/storage
parentMerge pull request #3712 from matrix-org/travis/register-admin-docs (diff)
parentremove errant yield (diff)
downloadsynapse-a2d872e7b3770c454569d838bf1bb92115d9f32a.tar.xz
Merge pull request #3708 from matrix-org/neilj/resource_Limit_block_event_creation
Neilj/resource limit block event creation
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/monthly_active_users.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/synapse/storage/monthly_active_users.py b/synapse/storage/monthly_active_users.py
index 7e417f811e..06f9a75a97 100644
--- a/synapse/storage/monthly_active_users.py
+++ b/synapse/storage/monthly_active_users.py
@@ -96,7 +96,10 @@ class MonthlyActiveUsersStore(SQLBaseStore):
             # While Postgres does not require 'LIMIT', but also does not support
             # negative LIMIT values. So there is no way to write it that both can
             # support
-            query_args = [self.hs.config.max_mau_value]
+            safe_guard = self.hs.config.max_mau_value - len(self.reserved_users)
+            # Must be greater than zero for postgres
+            safe_guard = safe_guard if safe_guard > 0 else 0
+            query_args = [safe_guard]
 
             base_sql = """
                 DELETE FROM monthly_active_users