File tree Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 1+ Fix an issue where "Lock timeout is getting excessive" warnings would be logged even when the lock timeout was <10 minutes.
Original file line number Diff line number Diff line change 2828
2929from synapse .metrics .background_process_metrics import wrap_as_background_process
3030from synapse .types import JsonDict
31+ from synapse .util .constants import ONE_HOUR_SECONDS , ONE_MINUTE_SECONDS
3132
3233if TYPE_CHECKING :
3334 from synapse .server import HomeServer
3435
3536logger = logging .getLogger ("synapse.app.homeserver" )
3637
37- ONE_MINUTE_SECONDS = 60
38- ONE_HOUR_SECONDS = 60 * ONE_MINUTE_SECONDS
39-
4038MILLISECONDS_PER_SECOND = 1000
4139
4240INITIAL_DELAY_BEFORE_FIRST_PHONE_HOME_SECONDS = 5 * ONE_MINUTE_SECONDS
Original file line number Diff line number Diff line change 4444from synapse .metrics .background_process_metrics import wrap_as_background_process
4545from synapse .storage .databases .main .lock import Lock , LockStore
4646from synapse .util .async_helpers import timeout_deferred
47+ from synapse .util .constants import ONE_MINUTE_SECONDS
4748
4849if TYPE_CHECKING :
4950 from synapse .logging .opentracing import opentracing
@@ -272,7 +273,7 @@ async def __aexit__(
272273 def _get_next_retry_interval (self ) -> float :
273274 next = self ._retry_interval
274275 self ._retry_interval = max (5 , next * 2 )
275- if self ._retry_interval > 5 * 2 ^ 7 : # ~10 minutes
276+ if self ._retry_interval > 10 * ONE_MINUTE_SECONDS : # >7 iterations
276277 logger .warning (
277278 "Lock timeout is getting excessive: %ss. There may be a deadlock." ,
278279 self ._retry_interval ,
@@ -352,7 +353,7 @@ async def __aexit__(
352353 def _get_next_retry_interval (self ) -> float :
353354 next = self ._retry_interval
354355 self ._retry_interval = max (5 , next * 2 )
355- if self ._retry_interval > 5 * 2 ^ 7 : # ~10 minutes
356+ if self ._retry_interval > 10 * ONE_MINUTE_SECONDS : # >7 iterations
356357 logger .warning (
357358 "Lock timeout is getting excessive: %ss. There may be a deadlock." ,
358359 self ._retry_interval ,
Original file line number Diff line number Diff line change 1+ #
2+ # This file is licensed under the Affero General Public License (AGPL) version 3.
3+ #
4+ # Copyright (C) 2025 New Vector, Ltd
5+ #
6+ # This program is free software: you can redistribute it and/or modify
7+ # it under the terms of the GNU Affero General Public License as
8+ # published by the Free Software Foundation, either version 3 of the
9+ # License, or (at your option) any later version.
10+ #
11+ # See the GNU Affero General Public License for more details:
12+ # <https://www.gnu.org/licenses/agpl-3.0.html>.
13+ #
14+
15+ # Time-based constants.
16+ #
17+ # Laying these out incrementally, even if only some are required, helps with
18+ # readability and catching bugs.
19+ ONE_MINUTE_SECONDS = 60
20+ ONE_HOUR_SECONDS = 60 * ONE_MINUTE_SECONDS
You can’t perform that action at this time.
0 commit comments