Skip to content

Commit 1eed9c0

Browse files
committed
Temporarily reduce scheduled task load
- reduce hardcoded task parallelism - add hardcoded post task sleep
1 parent 5500dbe commit 1eed9c0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

synapse/util/task_scheduler.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ class TaskScheduler:
100100
# Time before a complete or failed task is deleted from the DB
101101
KEEP_TASKS_FOR_MS = 7 * 24 * 60 * 60 * 1000 # 1 week
102102
# Maximum number of tasks that can run at the same time
103-
MAX_CONCURRENT_RUNNING_TASKS = 5
103+
MAX_CONCURRENT_RUNNING_TASKS = 1 # Beep: temporarily changed from 5
104104
# Time from the last task update after which we will log a warning
105105
LAST_UPDATE_BEFORE_WARNING_MS = 24 * 60 * 60 * 1000 # 24hrs
106106
# Report a running task's status and usage every so often.
107107
OCCASIONAL_REPORT_INTERVAL_MS = 5 * 60 * 1000 # 5 minutes
108108

109+
SLEEP_AFTER_TASK_S = 1
110+
109111
def __init__(self, hs: "HomeServer"):
110112
self._hs = hs
111113
self.server_name = (
@@ -456,6 +458,10 @@ async def wrapper() -> None:
456458
result = None
457459
error = f.getErrorMessage()
458460

461+
# Beep: sleep before we remove/complete the running task
462+
if TaskScheduler.SLEEP_AFTER_TASK_S > 0:
463+
await self._clock.sleep(TaskScheduler.SLEEP_AFTER_TASK_S)
464+
459465
await self._store.update_scheduled_task(
460466
task.id,
461467
self._clock.time_msec(),

0 commit comments

Comments
 (0)