From 7d20d353757d72d331b6da8e1e9c3822accb35cf Mon Sep 17 00:00:00 2001 From: RealKinetix Date: Mon, 29 Mar 2021 22:34:55 -0700 Subject: [PATCH 1/3] Maintenance time calculations should be done in minutes, not seconds. Should resolve #2336 --- evennia/server/portal/portal.py | 2 +- evennia/server/server.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/evennia/server/portal/portal.py b/evennia/server/portal/portal.py index d1af41a143..f3e29fb9a0 100644 --- a/evennia/server/portal/portal.py +++ b/evennia/server/portal/portal.py @@ -119,7 +119,7 @@ def _portal_maintenance(): _MAINTENANCE_COUNT += 1 - if _MAINTENANCE_COUNT % (3600 * 7) == 0: + if _MAINTENANCE_COUNT % (60 * 7) == 0: # drop database connection every 7 hrs to avoid default timeouts on MySQL # (see https://github.com/evennia/evennia/issues/1376) connection.close() diff --git a/evennia/server/server.py b/evennia/server/server.py index 4d09d8fdb6..fb112fe5cb 100644 --- a/evennia/server/server.py +++ b/evennia/server/server.py @@ -140,16 +140,16 @@ def _server_maintenance(): _GAMETIME_MODULE.SERVER_RUNTIME_LAST_UPDATED = now ServerConfig.objects.conf("runtime", _GAMETIME_MODULE.SERVER_RUNTIME) - if _MAINTENANCE_COUNT % 300 == 0: + if _MAINTENANCE_COUNT % 5 == 0: # check cache size every 5 minutes _FLUSH_CACHE(_IDMAPPER_CACHE_MAXSIZE) - if _MAINTENANCE_COUNT % 3600 == 0: + if _MAINTENANCE_COUNT % 60 == 0: # validate scripts every hour evennia.ScriptDB.objects.validate() - if _MAINTENANCE_COUNT % 3700 == 0: + if _MAINTENANCE_COUNT % 61 == 0: # validate channels off-sync with scripts evennia.CHANNEL_HANDLER.update() - if _MAINTENANCE_COUNT % (3600 * 7) == 0: + if _MAINTENANCE_COUNT % (60 * 7) == 0: # drop database connection every 7 hrs to avoid default timeouts on MySQL # (see https://github.com/evennia/evennia/issues/1376) connection.close() From 80a0a3ce70bcdc692bf6b95d3eefbf6596d23940 Mon Sep 17 00:00:00 2001 From: RealKinetix Date: Tue, 6 Apr 2021 17:25:08 -0700 Subject: [PATCH 2/3] Fixed related server test in the test suite with appropriate timing trigger. --- evennia/server/tests/test_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evennia/server/tests/test_server.py b/evennia/server/tests/test_server.py index 33a9341cae..0d4a217ed7 100644 --- a/evennia/server/tests/test_server.py +++ b/evennia/server/tests/test_server.py @@ -84,7 +84,7 @@ class TestServer(TestCase): _FLUSH_CACHE=DEFAULT, connection=DEFAULT, _IDMAPPER_CACHE_MAXSIZE=1000, - _MAINTENANCE_COUNT=3700 - 1, + _MAINTENANCE_COUNT=62 - 1, _LAST_SERVER_TIME_SNAPSHOT=0, ServerConfig=DEFAULT, ) as mocks: From 21bf565e572df781292f314ada67d396fecf6aa6 Mon Sep 17 00:00:00 2001 From: RealKinetix Date: Tue, 6 Apr 2021 17:43:49 -0700 Subject: [PATCH 3/3] Unsure how the last commit had an old edit, but this should fix tests now. --- evennia/server/tests/test_server.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/evennia/server/tests/test_server.py b/evennia/server/tests/test_server.py index 0d4a217ed7..a7933cd6ff 100644 --- a/evennia/server/tests/test_server.py +++ b/evennia/server/tests/test_server.py @@ -47,7 +47,7 @@ class TestServer(TestCase): _FLUSH_CACHE=DEFAULT, connection=DEFAULT, _IDMAPPER_CACHE_MAXSIZE=1000, - _MAINTENANCE_COUNT=600 - 1, + _MAINTENANCE_COUNT=5 - 1, ServerConfig=DEFAULT, ) as mocks: mocks["connection"].close = MagicMock() @@ -65,7 +65,7 @@ class TestServer(TestCase): _FLUSH_CACHE=DEFAULT, connection=DEFAULT, _IDMAPPER_CACHE_MAXSIZE=1000, - _MAINTENANCE_COUNT=3600 - 1, + _MAINTENANCE_COUNT=60 - 1, _LAST_SERVER_TIME_SNAPSHOT=0, ServerConfig=DEFAULT, ) as mocks: @@ -84,7 +84,7 @@ class TestServer(TestCase): _FLUSH_CACHE=DEFAULT, connection=DEFAULT, _IDMAPPER_CACHE_MAXSIZE=1000, - _MAINTENANCE_COUNT=62 - 1, + _MAINTENANCE_COUNT=61 - 1, _LAST_SERVER_TIME_SNAPSHOT=0, ServerConfig=DEFAULT, ) as mocks: @@ -102,7 +102,7 @@ class TestServer(TestCase): _FLUSH_CACHE=DEFAULT, connection=DEFAULT, _IDMAPPER_CACHE_MAXSIZE=1000, - _MAINTENANCE_COUNT=(3600 * 7) - 1, + _MAINTENANCE_COUNT=(60 * 7) - 1, _LAST_SERVER_TIME_SNAPSHOT=0, ServerConfig=DEFAULT, ) as mocks: