element-hq / element-hq/synapse
pid file not properly deleted leads to crash on start
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#9410](https://github.com/matrix-org/synapse/issues/9410).
---
### Description
The `homeserver.pid` file, for some reason, may not get deleted upon program exit, which leads to the program crashing once restarted. It seems like an equivalent to a `.lock` file issue with package managers. The reason the program crashes is because the file is there, but empty. Therefore, when it tries to read the pid, it cannot convert to integer on this instruction:
```
File "/opt/synapse/env/bin/synctl", line 352, in main
if os.path.exists(pidfile) and pid_running(int(open(pidfile).read())):
```
### Steps to reproduce
I couldn't reproduce it. However, I believe it happened due to update + reboots which perhaps made the program exit ungraciously. (I know for a fact I had to force reboot via the physical switch).
**To solve the issue:** Simply delete the .pid file in your matrix-synapse install location.
### Version information
- **Homeserver**: Yes, though it does not seem relevant to namedrop.
If not matrix.org:
- **Version**: 1.26.0
- **Install method**: pip
- **Platform**: Raspberry Pi 32bits (arm7vl)
Although the fix is easy, perhaps it would be relevant to add some measures to prevent reading an empty file then trying to cast the empty string as int.
Contributor guide
Assessment
This issue has not been assessed yet.