Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13155 closed Bug Report - Crash (fixed)

mythtv fails schema upgrade

Reported by: dhighey@… Owned by: Peter Bennett
Priority: major Milestone: 29.1
Component: MythTV - General Version: v29.0
Severity: high Keywords:
Cc: Ticket locked: no

Description

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: @�FB 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 '@�FB' 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

Subsequently found that by running mythtv-setup I was able to complete the database upgrade.

This issue was first reported to the rpmfusion.org as defect 4685.

Additional information below from that report by another user.

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.

Change History (7)

comment:1 Changed 6 years ago by Peter Bennett

Owner: set to Peter Bennett
Status: newassigned

comment:2 Changed 6 years ago by Peter Bennett

Change to master.toLocal8Bit() instead of master.toUtf8() to ensure we use the encoding that matches the environment where we are running.

comment:3 Changed 6 years ago by Peter Bennett <pbennett@…>

Resolution: fixed
Status: assignedclosed

In f5c7f266df056f36624010077bf71a578b740a82/mythtv:

Fixes #13155 - Schema upgrade fails intermittently

Fix incorrect conversion from QString to char* in upgrade SQL.

comment:4 Changed 6 years ago by Peter Bennett <pbennett@…>

In 83b32140f0aab7612eea1023edc1098706a23781/mythtv:

Fixes #13155 - Schema upgrade fails intermittently

Fix incorrect conversion from QString to char* in upgrade SQL.

(cherry picked from commit f5c7f266df056f36624010077bf71a578b740a82)

comment:5 Changed 6 years ago by Peter Bennett

Milestone: needs_triage29.1

comment:6 Changed 6 years ago by mloewen@…

I'm still getting the same error while trying to upgrade from 0.28 to 29. As above, it fails when trying to upgrade the schema from 1346 to 1347. I tried running the commands manually from the mysql> command line; they worked, but then mythbackend (and mythtv-setup) crashes with a SEGV on startup. Environment is Fedora 24, Linux version 4.11.12-100.fc24.x86_64. I compile from source (fixes/29 83b32140f0aab7612eea1023edc1098706a23781).

comment:7 Changed 6 years ago by Peter Bennett

Owner: changed from Peter Bennett to Peter Bennett
Note: See TracTickets for help on using tickets.