Sonarr process fails to terminate when requested via web page

Sonarr version (exact version): 2.0.0.4949
Mono version (if Sonarr is not running on Windows):5.2.0.224
OS: Linux raspberrypi 4.9.52-v7+ #1038
((Debug logs)):
(Make sure debug logging is enabled in settings and post the full log to hastebin/pastebin/dropbox/google drive or something similar, do not post them directly here)
Description of issue: For quite a while I have noticed that sonarr leaves a process or two spinning with high CPU utilisation when shutdown is requested via the system > status page, but only after sonarr has been running for a while, perhaps an hour or two of normal operation - rss checks etc. Invoking sonarr via the command line, waiting an hour or so, commanding shutdown then looking at the text logged to the console shows the lifecyclecontroller has requested shutdown but that’s it. I have let it sit in this condition for over two hours and there is no further text output.

To prove it is not a problem with my PI’s configuration I have clean installed xubuntu on a PC, installed nzbget, mono, sonarr and copied the sonarr databases across and can reproduce the problem precisely.

In addition I have installed nzbget and sonarr on a Windows PC, transferred the databases, then adjusted the all the paths in nzbdrone.db to make them ‘Windows friendly’ using sql search / update commands and found that sonarr shuts down correctly and cleanly when commanded via the system > status page.

How are you running Sonarr on the rpi?

If systemd or similar is used it could be restarting Sonarr after the request to shutdown.

Normally via an init script, which itself is kicked off by systemd these days. However, if I key in the mono command to start sonarr myself, the same problem is observed.

What do the ((trace logs)) of the shutdown process show?

17-10-12 04:19:55.1|Trace|Http|Req: 342 [POST] /api/system/shutdown
17-10-12 04:19:55.1|Info|LifecycleService|Shutdown requested.
17-10-12 04:19:55.1|Trace|EventAggregator|Publishing ApplicationShutdownRequested
17-10-12 04:19:55.2|Trace|EventAggregator|ApplicationShutdownRequested -> NzbDroneServiceFactory

No more entries appear in the trace log after that point and the remaining sonarr processes do not terminate, two of them spin with continual high CPU use. The only way forward in this situation is to kill the processes.

There should only be one instance, unless another is being started (though the first should exit). It sounds a lot like:

No other logging is done by Sonarr?

There is only one master process but it appears to start several threads with their own PIDs as part of its normal operations.

ps -ef | grep mono
pi 5540 1 14 06:28 ? 00:54:38 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe

ps -eLf | grep mono
pi 5540 1 5540 0 17 06:28 ? 00:01:15 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 5544 0 17 06:28 ? 00:00:25 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 5545 0 17 06:28 ? 00:00:06 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 5546 0 17 06:28 ? 00:00:05 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 5565 6 17 06:29 ? 00:23:55 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 5566 2 17 06:29 ? 00:09:46 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 5567 2 17 06:29 ? 00:09:19 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 5575 0 17 06:29 ? 00:00:01 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 5578 0 17 06:29 ? 00:00:03 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 5597 0 17 06:29 ? 00:00:00 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 10121 0 17 12:10 ? 00:00:17 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 14028 0 17 12:27 ? 00:00:10 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 15117 1 17 12:30 ? 00:00:13 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 18282 3 17 12:43 ? 00:00:06 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 18283 3 17 12:43 ? 00:00:05 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 18284 2 17 12:43 ? 00:00:04 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe
pi 5540 1 18671 0 17 12:45 ? 00:00:00 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe

There are absolutely no additional entries in the logs once the situation is encountered. Until the shutdown command is issued everything runs normally none spin at high CPU use. Continual high CPU use is only observed after shutdown is requested.

So … since the support tap seems to have been turned off, I decided to try another thing. A new database, ie as if sonarr has just been installed.

Both nzbdrone.db and log.db moved to simulate a new installaton, and sonarr started.

The problem persists even in this configuration clearly demonstrating that the problem lays with either sonarr itself or mono and not anything peculiar with my linux systems.

I wanted to check a few things before getting back to you as I didn’t have any further questions.

This appears to be a new issue with mono 5, or at least 5.2, though I have no idea what the issue could be. I tested with mono 4.8.0.524 and I was not able to reproduce this issue, but I do see it with 5.2.0.224, both with fresh installs of Sonarr. I left them running for an hour+ and then shut them down.

OK, thankyou for the answer. I’ll try downgrading to an earlier build of mono too.

Downgrading to mono 4.x fixed the problem.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.