element-hq / element-hq/synapse

Logging loop after SIGHUP when a `StreamHandler` is configured

Open
#6,550 0 comments 0 reactions 0 assignees View on GitHub
A-Logging T-Defect
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#6550](https://github.com/matrix-org/synapse/issues/6550).

---

If you use the default logging config, which has a `StreamHandler` pointing at sys.stderr, and do not set `--no-redirect-stdio`, then when you send synapse a SIGHUP, it will stack overflow and abort.

The problem appears to be that when you SIGHUP it, the streamhandler gets repointed at the redirected stderr, which goes back into a logger: so as soon as anything is logged, we get an infinite loop.

Contributor guide

Open the contributing guide

Research direction

Reproduce with the default logging config and a SIGHUP while leaving --no-redirect-stdio unset; trace how the StreamHandler pointing at sys.stderr is repointed to redirected stderr. Confirm the issue is resolved when SIGHUP no longer causes recursive logging, a stack overflow, or an abort.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.