Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#3913 closed defect (fixed)

After WOL'ing the DB server, mythfrontend connects to wrong host

Reported by: laga+mythtv@… Owned by: Nigel
Priority: minor Milestone: 0.21
Component: mythtv Version: head
Severity: medium Keywords:
Cc: Ticket locked: no



I've just configured mythfrontend to WOL my database server (which is also my master backend). The box wakes up fine, but mythfrontend does not realize that mysqld is available. Instead, it keeps retrying. It would seem to me that it tries to connect to localhost instead of using ~/.mythtv/mysql.txt. I'm running trunk r14355. Please see attached log:

laga@prometheus:~$ mythfrontend
2007-08-31 14:07:36.242 Using runtime prefix = /usr
2007-08-31 14:07:36.245 DPMS is disabled.
2007-08-31 14:07:40.402 Cannot find (ping) database host on the network
2007-08-31 14:07:40.422 New DB connection, total: 1
2007-08-31 14:07:40.427 Using WOL to wakeup database server (Try 1 of 5)
2007-08-31 14:08:10.441 Using WOL to wakeup database server (Try 2 of 5)
2007-08-31 14:08:40.451 Using WOL to wakeup database server (Try 3 of 5)
2007-08-31 14:09:10.465 Using WOL to wakeup database server (Try 4 of 5)
2007-08-31 14:09:40.477 Using WOL to wakeup database server (Try 5 of 5)
2007-08-31 14:10:10.489 WOL failed, unable to connect to database!
2007-08-31 14:10:10.490 Unable to connect to database!
2007-08-31 14:10:10.490 Driver error was [1/1045]:
QMYSQL3: Unable to connect
Database error was:
Access denied for user 'mythtv'@'localhost' (using password: YES)

QSqlQuery::exec: database not open
QSqlQuery::exec: database not open
2007-08-31 14:10:10.545 DB Error (KickDatabase):
}}} etc..

I've taken a look at mythdbcon.cpp but I couldn't find the root of the problem - I'm not a coder, though. I also made sure that the mysqld was indeed available by logging in remotely.



p.s.: here's my mysql.txt with the comments removed:

WOLsqlCommand=sudo etherwake -i eth1 <deleted>

Attachments (1)

pingtest-WOL.patch (1.1 KB) - added by Nigel 14 years ago.
Patch against recent SVN trunk

Download all attachments as: .zip

Change History (9)

comment:1 Changed 14 years ago by laga+mythtv@…

Putting my email address in here..

comment:2 Changed 14 years ago by maverik044

You need to disable the ping for it to work. The code defaults to localhost if it can not ping it the first time. Then when it tries to reconnect it uses localhost instead of the ip address set in mysql.txt. Set DBHostPing=no in ~/.mythtv/mysql.txt, this should fix your problem.

I had the same problem, disabling ping fixed it.

comment:3 Changed 14 years ago by paulh

Owner: changed from Isaac Richards to Nigel

comment:4 Changed 14 years ago by Nigel

Reporter: changed from anonymous to laga+mythtv@…
Status: newassigned

Hi Michael? Sorry I broke this for you. Could I get you to try the following patch:

Index: mythcontext.cpp
--- mythcontext.cpp     (revision 14249)
+++ mythcontext.cpp     (working copy)
@@ -862,6 +862,7 @@
     QString err;
     QString host = m_settings->GetSetting("DBHostName");
     int     port = m_settings->GetSetting("DBPort").toInt();
+    QString wake = m_settings->GetSetting("WOLsqlCommand");
     // Deal with missing hostname line, OR one without a value
     if (!host.length())
@@ -875,6 +876,14 @@
     if (host == "localhost" || host == "" || host == m_localhostname)
         doPing = false;
+    // The SQL server may be asleep, so wake it up. Slightly different
+    // logic to ConnectServer(), which attempts connection before wakeup.
+    if (doPing && wake.length())
+    {
+        myth_system(wake.ascii());
+        sleep(m_settings->GetNumSetting("WOLbackendReconnectWaitTime", 0));
+    }
     if (doPing && !ping(host, 3))  // Fail after trying for 3 seconds
         // Cause MSqlQuery to fail, instead of minutes timeout per DB value

comment:5 Changed 14 years ago by laga

Hi Nigel,

thanks for the quick reply. Sorry for not replying earlier - i keep forgetting to apply your patch. I'll try it later today and give you some feedback then.

Changed 14 years ago by Nigel

Attachment: pingtest-WOL.patch added

Patch against recent SVN trunk

comment:6 Changed 14 years ago by Nigel

Status: acceptedinfoneeded

I don't have a WOL backend to test, so I still can't apply this. Someone with the original fault, please test?

comment:7 Changed 13 years ago by Nigel

Resolution: fixed
Status: infoneededclosed

Slightly different fix was checked in as a part of [15431]

comment:8 Changed 13 years ago by Nigel

Milestone: unknown0.21
Note: See TracTickets for help on using tickets.