mythtv fails to connect to remote DB on inital boot

Bug #149268 reported by Rav
4
Affects Status Importance Assigned to Milestone
Mythbuntu
Fix Released
Low
Mario Limonciello
mythtv (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: mythtv-backend

The backend fails to connect to the DB which his located on a different machine on boot. After it boots, if I do it manually it works fine.

Here is the log file of mythtv after it fails to boot on startup:
2007-10-04 20:33:25.401 Using runtime prefix = /usr
2007-10-04 20:33:25.631 New DB connection, total: 1
2007-10-04 20:33:25.661 Unable to connect to database!
2007-10-04 20:33:25.679 Driver error was [1/2003]:
QMYSQL3: Unable to connect
Database error was:
Can't connect to MySQL server on 'surma' (101)

QSqlQuery::exec: database not open
QSqlQuery::exec: database not open
2007-10-04 20:33:25.813 DB Error (KickDatabase):
Query was:
SELECT NULL;
No error type from QSqlError? Strange...
2007-10-04 20:33:25.864 Failed to init MythContext, exiting.

Here is the log file when I do it manually:
2007-10-04 20:35:08.098 Using runtime prefix = /usr
2007-10-04 20:35:08.147 New DB connection, total: 1
2007-10-04 20:35:08.155 Connected to database 'mythconverg' at host: surma
2007-10-04 20:35:08.167 Current Schema Version: 1160
Starting up as the master server.

I think the ordering of the init script might need revising or something. Maybe my network has not been brought up when it tries to run mythtv.

Related branches

Revision history for this message
Mario Limonciello (superm1) wrote :

Is this on a machine with network manager in use? If so, try to setup DHCP via the manual network configuration utility instead of using network manager.

Changed in mythtv:
status: New → Incomplete
Revision history for this message
Rav (thecheatah) wrote : Re: [Bug 149268] Re: mythtv fails to connect to remote DB on inital boot

Yes, this machine use to use the NetworkManager.

Then I needed this machine to have a static IP so I set that in the
"/etc/network/interfaces" file. After that it has been working fine.

I apologize for not updating the bug report.

On 10/29/07, Mario Limonciello <email address hidden> wrote:
> Is this on a machine with network manager in use? If so, try to setup
> DHCP via the manual network configuration utility instead of using
> network manager.
>
> ** Changed in: mythtv (Ubuntu)
> Status: New => Incomplete
>
> --
> mythtv fails to connect to remote DB on inital boot
> https://bugs.launchpad.net/bugs/149268
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Changed in mythtv:
status: Incomplete → Invalid
Changed in mythbuntu:
status: New → Confirmed
Revision history for this message
David Morris (dave-greenacre) wrote :

Not sure how much time wants to be spent on this. Since a master backend with the database on a different machine isn't supported out of the box however it still needs fixing.

Changed in mythbuntu:
assignee: nobody → superm1
importance: Undecided → Low
Revision history for this message
laga (laga) wrote :

There might be a way to fix this.

NetworkManager seems to be able to run commands whenever it fiddles with interfaces. It looks like it's emulating the old ifup/ifdown behavior (see /etc/NetworkManager/dispatcher.d/01ifupdown).

We might be able to restart mythbackend whenever an interface is taken online. However, this can result in the backend being restart in the middle of a recording/transcoding job/commflagging job. (Just wondering: what happens if the master backend goes away when the slave is recording something?).

Another approach would require us to write a small script which would check (when the backend is started via its init script) if a slave backend is meant to connect to an external backend and make sure it's reachable, eg that a route to that network exists or something as simple as a ping. if it's unreachable, make Networkmanager restart the backend once a interface comes up.

Too complicated to be a nice and simple solution, though. :( Any thoughts? Of course, this should be configurable (disabled by default?).

Revision history for this message
Mario Limonciello (superm1) wrote :

I've got a fix in that may be able to take care of this in mythtv bzr.

Changed in mythtv:
status: Invalid → Fix Committed
Changed in mythbuntu:
status: Confirmed → Fix Committed
Revision history for this message
Mario Limonciello (superm1) wrote :

mythtv (0.20.2+fixes15096-0ubuntu2) hardy; urgency=low

  [ Mario Limonciello ]
  * mythtv-backend.init:
    - Require networking and remote file systems to be started before
      running. (LP: #149268)
    - Find the home directory of our USER and then create a symbolic
      link in that user's home directory for mysql.txt.
    - Add LSB support.

  [ Paul McEnery ]
  * More resilient init script PID handling (LP: #118538)

 -- Mario Limonciello <email address hidden> Mon, 17 Dec 2007 00:15:52 -0600

Changed in mythtv:
status: Fix Committed → Fix Released
Revision history for this message
sgunther (sgunther) wrote : FIX Re: mythtv fails to connect to remote DB on inital boot

My fix for this was as follows;

1. Move the init for mythbackend from 20 to 50.
2. Change the network configuration.

Details;
1. Move the init for mythbackend from 20 to 50.

Type:
sudo update-rc.d -f mythtv-backend remove

Echo:
Removing any system startup links for /etc/init.d/mythtv-backend ...
   /etc/rc0.d/K20mythtv-backend
   /etc/rc1.d/K20mythtv-backend
   /etc/rc2.d/S20mythtv-backend
   /etc/rc3.d/S20mythtv-backend
   /etc/rc4.d/S20mythtv-backend
   /etc/rc5.d/S20mythtv-backend
   /etc/rc6.d/K20mythtv-backend

Type:
sudo update-rc.d mythtv-backend defaults 50

Echo:
Adding system startup for /etc/init.d/mythtv-backend ...
   /etc/rc0.d/K50mythtv-backend -> ../init.d/mythtv-backend
   /etc/rc1.d/K50mythtv-backend -> ../init.d/mythtv-backend
   /etc/rc6.d/K50mythtv-backend -> ../init.d/mythtv-backend
   /etc/rc2.d/S50mythtv-backend -> ../init.d/mythtv-backend
   /etc/rc3.d/S50mythtv-backend -> ../init.d/mythtv-backend
   /etc/rc4.d/S50mythtv-backend -> ../init.d/mythtv-backend
   /etc/rc5.d/S50mythtv-backend -> ../init.d/mythtv-backend

2. Change the network configuration.
On the desktop select;
Applications > System > Network

Type your sudo password if prompted.

Select your wired connection on the "Connections" tab.

Select "Properties"

Uncheck "Enable Roaming Profile"

Change the configuration to DHCP or Static.

Note: If you do use DHCP I highly recommend a static DHCP assignment in your router or you may have problems in the future.

Reboot.....

And for me the problem is fixed.

Revision history for this message
Mario Limonciello (superm1) wrote :

Fixed in Mythbuntu 8.04 Alpha 1

Changed in mythbuntu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.