diff options
author | Erik Johnston <erikj@jki.re> | 2018-09-21 09:26:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-21 09:26:30 +0100 |
commit | ad53a5497d77d28a1a01d77945af6c6d1bee0bb1 (patch) | |
tree | 7278d1e19052d827e11b74918cba5d79fe1f74a3 | |
parent | Always LL ourselves if we're in a room to simplify clients (#3916) (diff) | |
parent | Add missing logger (diff) | |
download | synapse-ad53a5497d77d28a1a01d77945af6c6d1bee0bb1.tar.xz |
Merge pull request #3927 from matrix-org/erikj/handle_background_errors
Handle exceptions thrown by background tasks
-rw-r--r-- | changelog.d/3927.misc | 1 | ||||
-rw-r--r-- | synapse/metrics/background_process_metrics.py | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/changelog.d/3927.misc b/changelog.d/3927.misc new file mode 100644 index 0000000000..4bd8e25f67 --- /dev/null +++ b/changelog.d/3927.misc @@ -0,0 +1 @@ +Log exceptions thrown by background tasks diff --git a/synapse/metrics/background_process_metrics.py b/synapse/metrics/background_process_metrics.py index 167167be0a..173908299c 100644 --- a/synapse/metrics/background_process_metrics.py +++ b/synapse/metrics/background_process_metrics.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging import threading import six @@ -23,6 +24,9 @@ from twisted.internet import defer from synapse.util.logcontext import LoggingContext, PreserveLoggingContext +logger = logging.getLogger(__name__) + + _background_process_start_count = Counter( "synapse_background_process_start_count", "Number of background processes started", @@ -191,6 +195,8 @@ def run_as_background_process(desc, func, *args, **kwargs): try: yield func(*args, **kwargs) + except Exception: + logger.exception("Background process '%s' threw an exception", desc) finally: proc.update_metrics() |