[Solved] Mythtv with ACPI sometimes fails to shutdown

For discussion of topics specific to MythTV on linux
Post Reply
ceesquared
Junior
Posts: 17
Joined: Tue Dec 11, 2018 4:20 pm
Location: Marlborough UK
Great Britain

[Solved] Mythtv with ACPI sometimes fails to shutdown

Post by ceesquared »

I have a combined FE/BE with Mythtv v31 on Ubuntu 18.04.5. TBS 6904 tuner. There is no internet connection. Sometimes( 1 in 20 maybe) the box fails to shutdown. the display shows BE has shutdown(message posted) but still FE is shown. Alt-Tab to get a terminal ( I have terminal in startup). then sudo shutdown -h now works, and box shuts down. The problem is, of course, that it is intermittent, usually shutdown works but occasionally it hangs. WTF is going on!
Additional information. 8 Jun 21
FE shows message "Backend shutdown in 5 secs." ( N.B. no countdown shown) and then it stalls for about 10 secs and the shows message backend off line.
Alt-Tab to terminal and shutdown entry shows "[FAILED] failed to shut down plymouth off service" and then later it shows a stop job running with countdown for 1:30. After countdown the shutdown is completed.
9 Jun 21.
Same Failure but pidof mythbackend returns 1003(mythbackend.service not tested). Close FE, restart FE, " cannot connect to backend" but still pidof mythbackend returns 1003
sudo shutdown etc. works but it now gives a blank screen(no terminal output) and shuts down after about 1:30 as before. The subsequent restart and shutdown using the remote is OK.

Additional info. 17 Jun 21.
GRUB amended on 16 Jun from "quiet" "splash" to "quiet"
Failed on am 17 Jun as before. sudo shutdown used as before. Blank screen then full shutdown after 60 sec.
Restarted box as normal. On off selected on remote, there was a 25 sec. wait in standby and then 5 sec. countdown and then complete shutdown.
N.B. there has been numerous successful startup/shutdowns on ACPI during the intervening time, probably 3 per day.

Additional info. 30 Aug 21.
Same fault as before, but this time I investigated the backend log. In it I found
"Aug 30 17:57:35 mythtv mythbackend: mythbackend[933]: E DVBRead mpeg/mpegstreamdata.cpp:761 (ProcessPAT) MPEGStream[1](0x7f82b81aa1d8): ProcessPAT: Program not found in PAT. Rescan your transports.
Aug 30 17:57:35 mythtv mythbackend: mythbackend[933]: E DVBRead mpeg/mpegstreamdata.cpp:373 (CreatePATSingleProgram) MPEGStream[1](0x7f82b81aa1d8): Desired program #8931 not found in PAT.#012#011#011#011Cannot create single program PAT."
I have rescanned before, but it still fails. Could the "Desired program #8931 not found in PAT.#012#011#011#011Cannot create single program PAT." be a clue?

Additional info 18 Nov. 21
Still the same fault. 'sudo reboot -f' works to shutdown and reboot to get it to restart & shutdown OK. If I had a script that looked for a PID and after, say, 1 min issued a reboot command as a 'I've had enough' would that work or would the script stop a normal shutdown?

Additional info 19 Nov 21.
Still the same fault. ps aux | grep myth returns that (I believe) mythbackend and mythfrontend.real are active and have a pid. However,
killall mythfrontend and mythfrontend.real both reply that 'no process found' ( despite the FE being visible on the screen).
sudo killall mythbackend has no effect( it has a pid of 956). Do I have a linux problem or a mythtv problem? Thank goodness that 'sudo reboot -f' works.

Additional info 29 Jun. 22
Still the same fault, but I appeared to have narrowed it down. I have run mythfrontend.real on its own and I still have the same fault so it appears that mythfrontend.real is not shutting down properly. I could Killall mythfrontend.real with SIGKILL but does this affect anything?( remember, I am going to powerdown anyway) Any thoughts would be appreciated before I go ahead.
Last edited by ceesquared on Sat Oct 08, 2022 7:46 pm, edited 1 time in total.
ceesquared
Junior
Posts: 17
Joined: Tue Dec 11, 2018 4:20 pm
Location: Marlborough UK
Great Britain

Re: Mythtv with ACPI sometimes fails to shutdown

Post by ceesquared »

After a complete reload of Ubuntu, I removed SNAP. According to my searches, the Ubuntu version of Mythtv available on SNAP was different to the published version of mythtv. I changed the shutdown to 'sudo systemctl poweroff -force'. The result was that Mythtv did a normal shutdown most of the time, but occasionally there was a delay of about 90 secs. before shutdown which could be significant. As a result I would call this 'solved' but not cured. Occasionally there was a message that there was a delay in shutting down some modules, that incuded 'mythfrontend.re', which ties in with my findings at 19 Nov 21 and 29 Jun. 22.
mtvf2894
Junior
Posts: 81
Joined: Sat Apr 10, 2021 2:33 pm
Great Britain

Re: [Solved] Mythtv with ACPI sometimes fails to shutdown

Post by mtvf2894 »

Not the same problem but this "solves" the general 90 secs timeout problem for me:

Code: Select all

sudo nano /etc/systemd/system.conf

#DefaultTimeoutStartSec=90s
#DefaultTimeoutStopSec=90s
DefaultTimeoutStartSec=10s
DefaultTimeoutStopSec=10s
If it doesn't timeout within 10 secs it isn't going to matter giving it more time in my opinion ;)

It at least stops 90 secs delays and reduces them to a more acceptable 10 secs obviously adjust as you see fit.
Current: v32 now v33.1 / Lubuntu 22.04 / AMD APU
Previous: v31 / Lubuntu 20.10 / AMD APU
Historic: Mythbuntu / NVIDIA GFX
ceesquared
Junior
Posts: 17
Joined: Tue Dec 11, 2018 4:20 pm
Location: Marlborough UK
Great Britain

Re: [Solved] Mythtv with ACPI sometimes fails to shutdown

Post by ceesquared »

Thanks mtvf2984. It was the whereabouts of 'DefaultTimeoutStopSec' that I was looking for. I will change it when I have chance, but as I am shutting down anyway, it is low on the priorities.
ceesquared
Junior
Posts: 17
Joined: Tue Dec 11, 2018 4:20 pm
Location: Marlborough UK
Great Britain

Re: [Solved] Mythtv with ACPI sometimes fails to shutdown

Post by ceesquared »

At last, a full solved. Mythtv developers, we appear to have a race condition with more than one core. As originally posted, the problem only occurred occasionally. This was solved by putting in 'shutdown.sh' in backend setup which consisted of:-
sync
sudo killall mythfrontend
sudo killall mythfrontend.real
sleep 2
sudo shutdown -P now &
exit
and it works! The race is avoided by killing all mythfrontend and then waiting before calling shutdown whereas before it went straight to shutdown and hoped that bash closed mythfrontend before mythbackend closed(which it normally did).
Post Reply