Won't shutdown

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

mathog
Senior
Posts: 147
Joined: Thu Dec 15, 2016 5:22 pm
United States of America

Won't shutdown

Post by mathog »

Our MythTV system seems to have wedged itself somehow.

When an exit from the frontend is requested it will never shut down. On the usual shutting down screen at the top it says:

Code: Select all

mythtv is in a daily wakeup/shutdown period ...
From the command line it does more or less the same thing:

Code: Select all

mythshutdown -x
In a daily wakeup period (1).
Not OK to shutdown
This period, whatever it is, never ends, so the only way to shutdown is with something dramatic, like a "poweroff" from a terminal.

I looked around in the log files and didn't find "period" at all, or anything that looked like a problem for "wakeup". Also, I don't even know what a "daily wakeup/shutdown" means. Up/down are set by whatever will be recorded, and those are whenever, so there are days where nothing would record and the box would never come up (or down.) Here are the last few messages relating to "shutdown" in mythbackend.log

Code: Select all

mythbackend.log:Feb 19 13:24:59 mediahog mythbackend: mythbackend[1308]: N Scheduler scheduler.cpp:3123 (HandleIdleShutdown) Client is connected, removing startup block on shutdown
mythbackend.log:Feb 19 13:30:14 mediahog mythbackend: mythbackend[1308]: N Scheduler scheduler.cpp:3292 (HandleIdleShutdown) Blocking shutdown because of a connected client
mythbackend.log:Feb 19 14:46:42 mediahog mythbackend: mythbackend[1521]: N Scheduler scheduler.cpp:3123 (HandleIdleShutdown) Client is connected, removing startup block on shutdown
For some reason there was no records added to mythfilldatabase.log today, but there were for yesterday when this "no way out" issue was not present. So mythfilldatabase was run manually as the user for the MythTV backend. Checked Schedules Direct and no problem logging in with those credentials, and account is good to 2026. The log file looks more or less the same as it has going back a few months. So mythfilldatabase can be run, but it isn't run by the backend currently. After doing that, tried to exit the front end, and it still had the same wakeup/shutdown period message, although now alternating with one about a current recording.

Using the account that the backend runs in, ran the optimize_mythdb.pl script. Same message, no way out of front end. Rebooted (in case some of these changes need that to "take".) Problem persists. mythfilldabase.log was not modified after this reboot, which might be a clue.

What do I need to kick to get it out of this state? Seems like there is a lock file or flag in the database which is set and needs to be unset.

Thanks.
white_haired_uncle
Senior
Posts: 563
Joined: Thu Feb 23, 2023 8:55 pm
Location: Safe outside my gilded cage
United States of America

Re: Won't shutdown

Post by white_haired_uncle »

There's a command that's run to check that it's okay to shutdown the BE. I remember a problem, probably on recent versions of Ubuntu, where one script always thought someone was logged in. I'd look at http://mythbackend:6544/setupwizard/general under Shutdown/Wakeup Options to see what's being run (though I suspect mythbackend.log would show that).

However, since the log specifically says "Blocking shutdown because of a connected client" I kind of doubt that will help. Perhaps http://mythbackend:6544/dashboard/status will provide a clue by showing a FE online or something. I just barely remember a sort of similar situation where I needed to restart an FE when the BE was "wedged" kind of sort of like yours, but then I don't shutdown regularly.

If you're familiar with mysql, you might look at the inuseprograms table for a clue.

Interesting point about mythfilldatabase. If the BE has nothing set to record and shuts down, I wonder if it will every wake up to run mythfilldatabase?

Hmm. There used to be a setting for when mythfilldatabase could be run automatically, but I don't see it in the new web app. I remember having customers with backups (not mythtv) that ran once per day and when something happened and they ran them during the day they wouldn't run that night (since it had already run that "day") so they'd run them again manually the next day.... No idea if something like that could happen with mythfilldatabase.
User avatar
bill6502
Developer
Posts: 2439
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Won't shutdown

Post by bill6502 »

@, what does this return: mythshutdown --check ; mythshutdown --status ; echo $?
mathog
Senior
Posts: 147
Joined: Thu Dec 15, 2016 5:22 pm
United States of America

Re: Won't shutdown

Post by mathog »

bill6502 wrote:
Thu Feb 20, 2025 3:49 pm
@, what does this return: mythshutdown --check ; mythshutdown --status ; echo $?

Code: Select all

Recording in progress...
In a daily wakeup period (1).
Not OK to shutdown
Recoding in progress...
In a daily wakup period (1).
72
I found that if I right click and run mythfilldatabase from the frontend it appears to run (no error messages or anything like that) but nothing logs to /var/log/mythtv/mythfilldatabase.log.

Also the file

/var/log/mysql/error.log

is full of "Got an error reading communication packets". Looking back at older versions of that, it has been that way for a long long time, so that isn't the immediate problem.

There are two storage areas, mythdbstorage and mythdbstorage2, which are on different partitions. The latter was at 100% and no recordings had been placed there in almost a year, but small files had. Using mythweb some older recordings in there were deleted, but the corresponding files did not go away. Those were removed from the command line, and today there are new recordings there, but the original problem remains. I need to run the find_orphans script.
mathog
Senior
Posts: 147
Joined: Thu Dec 15, 2016 5:22 pm
United States of America

Re: Won't shutdown

Post by mathog »

white_haired_uncle wrote:
Thu Feb 20, 2025 1:38 pm
I'd look at http://mythbackend:6544/setupwizard/general under Shutdown/Wakeup Options to see what's being run...
I will try that later. At the moment that sort of command isn't working when tried from another machine. The firewall is probably blocking access to that port.
User avatar
bill6502
Developer
Posts: 2439
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Won't shutdown

Post by bill6502 »

@mathog, the output of this please:

Code: Select all

mysql --user=mythtv --password --execute "SELECT * FROM settings WHERE value LIKE 'DailyWakeup%'" mythconverg
Password is from your config.xml file.
mathog
Senior
Posts: 147
Joined: Thu Dec 15, 2016 5:22 pm
United States of America

Re: Won't shutdown

Post by mathog »

Code: Select all

mysql --user=mythtv --password --execute "SELECT * FROM settings WHERE value LIKE 'DailyWakeup%'" mythconverg
Enter password: 
+-------------------------+-------+----------+
| value                   | data  | hostname |
+-------------------------+-------+----------+
| DailyWakeupEndPeriod1   | 23:56 | NULL     |
| DailyWakeupEndPeriod2   | 00:00 | NULL     |
| DailyWakeupStartPeriod1 | 23:58 | NULL     |
| DailyWakeupStartPeriod2 | 00:00 | NULL     |
+-------------------------+-------+----------+
mathog
Senior
Posts: 147
Joined: Thu Dec 15, 2016 5:22 pm
United States of America

Re: Won't shutdown

Post by mathog »

There is no dashboard on this system. It is v30.0+fixes on Ubuntu LTS 18.04.06. I should probably update...
User avatar
bill6502
Developer
Posts: 2439
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Won't shutdown

Post by bill6502 »

I don't know that it will help. There's a comment in the mythwelcome code that says the four periods are only applicable to a standalone frontend.
If you have such a beast, then mythwelcome --setup <MAY> work. I don't have one to test on and on combined FE/BE, the options don't appear.
Did you just add the wakeup periods?
mathog
Senior
Posts: 147
Joined: Thu Dec 15, 2016 5:22 pm
United States of America

Re: Won't shutdown

Post by mathog »

I have no idea where the wakeup periods came from. I asked my wife if she had changed anything two days ago in a programming rule and she didn't recall having done so. I ran "mythwelcoe --setup" but there were no relevant options. There was a line to run xterm, which is odd, because that isn't on the menu.

I just tried increasing max_allowed_packets in the two MySQL files that listed it, from 16 M to 64 M, and then to 256 M. However following a

service mysql restart

it just resumed logging "Got an error reading communication packets". One every 30s, like so:

Code: Select all

2025-02-20T20:59:57.489772Z 61 [Note] Got an error reading communication packets
2025-02-20T21:00:27.514868Z 64 [Note] Got an error reading communication packets
2025-02-20T21:00:57.426241Z 67 [Note] Got an error reading communication packets
2025-02-20T21:01:27.468069Z 70 [Note] Got an error reading communication packets
2025-02-20T21:01:57.487134Z 73 [Note] Got an error reading communication packets
mathog
Senior
Posts: 147
Joined: Thu Dec 15, 2016 5:22 pm
United States of America

Re: Won't shutdown

Post by mathog »

Fixed it! Well, at least for now. Exit out of mythfrontend into MythWelcome. Press "i" (had to attach a keyboard to the computer, normally it only uses an IR remote). This brings up a menu that shows the daily wakeup/shutdown times. They showed the ones from a couple of posts up. Set those both to 00:00 and saved. Mythwelcome dropped the nonsense and allowed a shutdown on the idle system.

I figured this out from reading this page:

https://www.mythtv.org/wiki/Mythwelcome

I had also previously deleted every recording rule I could find that was near that time, but that did nothing.

I still need to figure out why mythfilldatabase.log isn't getting any records though. Maybe this will fix it? Wouldn't that be strange.
User avatar
bill6502
Developer
Posts: 2439
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Won't shutdown

Post by bill6502 »

If that doesn't help, see what this says:

Code: Select all

$ curl --header Accept:application/json localhost:6544/Myth/GetSetting?Key=MythFillDatabasePath\&HostName=_GLOBAL_

# Expect this:
{"String": "mythfilldatabase"}
If there is a full path to mythfilldatabase, that's wrong and prevents logging.
mathog
Senior
Posts: 147
Joined: Thu Dec 15, 2016 5:22 pm
United States of America

Re: Won't shutdown

Post by mathog »

Rebooted system. Got into mythwelcome, ctrl right click with mouse to get menu, ran mythfilldatabase. Can see it running with "ps -ef", account is the one used by the frontend (let's call it "frontend"), which is different than the one used by the backend ("mythtv"). Ran the usual amount of time and Mythwelcome showed "grabbing EPG data" while it ran. When it finished the system shut down (because nothing was recording or near to be recording). Rebooted. Checked /var/log/mythtv, and nope, nothing added to mythfilldatabase.log. Maybe it only logs there if the backend starts it?
User avatar
bill6502
Developer
Posts: 2439
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Won't shutdown

Post by bill6502 »

What was the output of the curl? Note you can change localhost to the IP or hostname of the backend and run it remotely.
mathog
Senior
Posts: 147
Joined: Thu Dec 15, 2016 5:22 pm
United States of America

Re: Won't shutdown

Post by mathog »

bill6502 wrote:
Thu Feb 20, 2025 9:54 pm
What was the output of the curl? Note you can change localhost to the IP or hostname of the backend and run it remotely.
The same as the example you posted, no path. Let's see if the EPG does what it should tomorrow

As long as I was working on the system the Ubuntu package update/upgrades were run. When it came back up /var/log/mysql/error.log started logging the packet error messages at 30 second intervals, as before. So all the mythtv processes OTHER than mythbackend were stopped, and those went away. Then mythwelcome was started (from the account where it normally runs) and the error messages returned. This also starts mythfrontend. Finally mythwelcome only was stopped, leaving mythfrontend running, and the packet errors every 30 seconds stopped. So apparently those packet errors which repeat every 30s are from Mythwelcome. Maybe all of them? Anyway, poking around in mythfrontend did not make any of these entries in that log file. This included opening the TV schedule and moving around in it, and leaving it sitting for several minutes in the "upcoming recordings" window.
Post Reply