This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid incrementing bg process utime/stime counters by negative durati…
…ons (#14323)
- Loading branch information
David Robertson
authored
Oct 31, 2022
1 parent
7911e28
commit 2bb2c32
Showing
6 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a bug introduced in Synapse 0.34.0rc2 where logs could include error spam when background processes are measured as taking a negative amount of time. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from unittest import TestCase as StdlibTestCase | ||
from unittest.mock import Mock | ||
|
||
from synapse.logging.context import ContextResourceUsage, LoggingContext | ||
from synapse.metrics.background_process_metrics import _BackgroundProcess | ||
|
||
|
||
class TestBackgroundProcessMetrics(StdlibTestCase): | ||
def test_update_metrics_with_negative_time_diff(self) -> None: | ||
"""We should ignore negative reported utime and stime differences""" | ||
usage = ContextResourceUsage() | ||
usage.ru_stime = usage.ru_utime = -1.0 | ||
|
||
mock_logging_context = Mock(spec=LoggingContext) | ||
mock_logging_context.get_resource_usage.return_value = usage | ||
|
||
process = _BackgroundProcess("test process", mock_logging_context) | ||
# Should not raise | ||
process.update_metrics() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters