Bug 4685

Summary: mythtv fails schema upgrade
Product: Fedora Reporter: David HIghley <david.m.highley>
Component: mythtvAssignee: Richard <hobbes1069>
Status: RESOLVED FIXED    
Severity: major CC: jarod, rpmfusion
Priority: P1    
Version: 26   
Hardware: x86_64   
OS: GNU/Linux   
namespace:

Description David HIghley 2017-10-14 04:03:59 CEST
After upgrading to mythtv-backend-29.0-1.fc26.x86_64 the back end fails to start.

The log file has the following error listed.

2017-10-13 03:45:08.076484 E [16990/16990] CoreContext dbcheck.cpp:411 (performUpdateSeries) - DB Error (Performing database upgrade): 
Query was: @�^F^B 
Error was: Driver error was [2/1064]:
QMYSQL: Unable to execute query
Database error was:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@�^F^B' at line 1

2017-10-13 03:45:08.076490 E [16990/16990] CoreContext dbcheck.cpp:519 (UpgradeTVDatabaseSchema) - Database schema upgrade failed.
2017-10-13 03:45:08.076671 E [16990/16990] CoreContext main_helpers.cpp:571 (run_backend) - Couldn't upgrade database to new schema
Comment 1 Richard 2017-10-15 04:44:59 CEST
I didn't run into this problem when I upgraded my combined FE/BE system... Did you upgrade all the myth related packages at the same time?
Comment 2 David HIghley 2017-10-15 05:19:13 CEST
Yes all mythtv packages were upgraded at same time. What script is the log message indicating the bad SQL syntax? Maybe it can be fixed if I knew where the script is.
Comment 3 Richard 2017-10-15 05:21:03 CEST
Not really sure... might want to post to the mythtv user mailing list. There's not really enough detail here to make an educated guess.
Comment 4 Trevor Cordes 2017-10-18 09:45:25 CEST
I just got the same error here.

Thread about this here, guy found a workaround but I can't tell what he did:
http://www.deb-multimedia.org/lurker/message/20170802.154941.c5ffe016.pt-BR.html
http://www.deb-multimedia.org/lurker/message/20170802.173805.4e7f7d6e.pt-BR.html

The cpp file referenced is in the source code, so you need to check the source.  I'm doing that now to try to figure this out.

I'll post here if I figure anything out.  Plz do the same.

Oh ya, update the bug title here to be "mythtv" instead of "mythv", didn't find it on my first search, only by looking at recent bugs.
Comment 5 Trevor Cordes 2017-10-18 10:09:44 CEST
The guy on that thread was right.  Seems like master.toUtf8() on 3361 of libmythtv/dbcheck.cpp is buggy.  Perhaps what we have in common is we have our locale's set to something myth doesn't expect?  Just a guess.

Here's the workaround, but only run this if you schema is currently at 1346!!

Get a cmd line into your mythtv mysql server.  Run the commands that the 1346 section of that cpp file shows.  Here they are for those who don't want to sift through source.  You must change the "yourhost" type values to what suits your setup.  Ignore the # lines they are just my comments.

insert into settings (value,data,hostname) values ('MasterServerName' ,'yourhost.yourdomain.com',null);

insert into settings (value,data,hostname) select 'BackendServerAddr', data, hostname from settings where value = 'BackendServerIP';
# seems to put in the wrong address if you have 2 hostnames, but things still seem to work so I just left it alone

update settings a, settings b set b.data = a.data where a.value = 'BackendServerIP6' and b.hostname = a.hostname and b.value = 'BackendServerAddr' and b.data = '127.0.0.1' and a.data != '::1' and a.data is not null and a.data != '';
# noop if you don't have an ipv6 setup

update settings a, settings b, settings c set c.data = a.data where a.value = 'MasterServerIP' and b.value = 'MasterServerName' and c.value = 'BackendServerAddr' and c.hostname = b.data;
# was noop on my box

delete from settings where value in ('WatchTVGuide');

update settings set data=1347 where value='DBSchemaVer';

Then have systemd restart mythtv-backend and it should update to the latest version and run fine.  Works for me!

If someone wants to bother, it would be nice to put this as a bug on the mythtv bugzilla so upstream can fix it.  They need to fix that Utf8 call which is almost certainly the problem since that string does not appear anywhere else in the cpp file.
Comment 6 David HIghley 2017-10-18 12:47:12 CEST
Sorry, I did not loop back earlier on this issue. I was able to complete the database upgrade by running mythtv-setup. Then I was able to start the backend and all seems to be working. It did squawk about not being able to do a backup as I ran the command from my account as the mythv user does not allow an interactive login.

It is now reported in the Mythtv TRAC system as report #13155. I did take over most of the comments to that report.
Comment 7 Richard 2017-10-23 22:00:00 CEST
It looks like a commit has been made to fixes/29 so this should be resolved when I get a chance to do new builds.
Comment 8 Richard 2018-01-07 15:05:09 CET
I believe this is fixed, please reopen if that's not the case.