element-hq / element-hq/synapse

Dæmonised synapse does not close file descriptors

Open
#9,099 0 comments 0 reactions 0 assignees View on GitHub
S-Minor 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 [#9099](https://github.com/matrix-org/synapse/issues/9099).

---

Axel Beckert (@xtaran) [writes](https://bugs.debian.org/920339#67) in a bug report about Synapse hanging on start:

> ```
> 9500 root 20 0 7684 2608 1352 S 0.0 0.3 25:57.98 ├─ SCREEN -RdU
> 9501 root 20 0 7264 2512 1772 S 0.0 0.3 0:00.65 │ ├─ bash
> 2658 root 20 0 178M 125M 49080 S 0.0 13.6 1:24.26 │ │ └─ aptitude -u
> 4501 root 20 0 12616 7496 1684 S 0.0 0.8 0:00.40 │ │ ├─ dpkg --status-fd 66 --configure --pending
> 4970 root 20 0 19836 13500 3604 S 0.0 1.4 0:01.32 │ │ │ ├─ perl -w /usr/share/debconf/frontend /var/lib/dpkg/info/matrix-synapse.postinst configure
> 4502 root 20 0 1468 380 332 S 0.0 0.0 0:00.00 │ │ │ └─ sh -c (test -x /usr/lib/needrestart/dpkg-status && /usr/lib/needrestart/dpkg-status || cat > /dev/null)
> 4503 root 20 0 1468 68 0 S 0.0 0.0 0:00.00 │ │ │ └─ sh -c (test -x /usr/lib/needrestart/dpkg-status && /usr/lib/needrestart/dpkg-status || cat > /dev/null)
> 4504 root 20 0 1468 380 332 S 0.0 0.0 0:00.02 │ │ │ └─ sh /usr/lib/needrestart/dpkg-status
> 3499 root 20 0 178M 125M 49080 S 0.0 13.6 0:00.00 │ │ └─ aptitude -u
> [...]
> 5066 matrix-sy 20 0 69700 46988 6964 S 0.0 5.0 0:19.14 ├─ python3 -m synapse.app.homeserver --config-path /etc/matrix-synapse/homeserver.yaml --config-path /etc/matrix-synapse/conf.d/ --daemonize
> 5067 matrix-sy 20 0 69700 46988 6964 S 0.0 5.0 0:02.13 │ └─ python3 -m synapse.app.homeserver --config-path /etc/matrix-synapse/homeserver.yaml --config-path /etc/matrix-synapse/conf.d/ --daemonize
> ```
> So synapse has already forked, the init script seems to have exited
> already and even the postinst script has exited already. The question
> is what causes debconf to wait?
>
> <…>
>
> I suspect — based on the name part "matrix-synapse." that this zombie
> was either the `matrix-synapse.postinst` script or the
> `matrix-synapse.config` script.
>
> Looking with lsof what's still opened by the debconf frontend process
> (pid 4970), I noticed these two pipes:
>
> <…>
>
> Grepping through the whole process space, I noticed that at least one
> of these pipes is connected to the python3 process running
> matrix-synapse which looks odd to me:
>
> <…>
>
> So it seems that matrix-synapse's `--daemonize` doesn't properly close
> file descriptors upon forking — which is likely an upstream issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.