Win waking from sleep and unable to connect to mySQL
#1
Hi all,

I have a mySQL setup on an unraid server with win 7 clients. My HTPC (atom + ION) is set to sleep when not being used. This occurs after an auto-close of XBMC after some time of no activity (as when using ?Dharma? XBMC would not let the HTPC sleep if it was still running - I think that this has changed with Frodo))

When the HTPC wakes from sleep and XBMC is started again it cannot connect to the mySQL database. The log file has errors saying it cannot connect to the database. If I close XBMC and restart it I am able to connect to the database immediately. I have been unable to determine if this is related to the drives in the server being spun down, however this behaviour is new with Frodo. Using Eden, XBMC would sit there thinking while the drives in the server spun up and then would connect without any intervention. My settings have not changed since upgrading from Eden to Frodo.

I want to keep the HTPC sleeping and spin down the server drives when not in use

I see a few ways to try and fix this
1. turn off auto-close of XBMC and see if that has any effect. I doubt it though
2. Extend the network timeout in Frodo, if this is able to be updated (maybe samba clienttimeout? or curlclienttimeout?)
3. Create a batch file to spin up the drives on the server and then start XBMC (although this wont work if XBMC is already running when the HTPC wakes from sleep)

Has anyone experienced the same issue that I am seeing and have any advice on how to sort it out, or knowledge if the options above will work?

Thanks
Openelec on ASRock ION 330 / Kodi on Win 7 PC
Reply
#2
Update

Log file when can't connect to mySQL database http://pastebin.com/5U8H96pU
Log file when am able to connect to mySQL database http://pastebin.com/3WBH5c79

I can't see anything obvious in these - other than not being able to connect.

and yes - I know I don't need to use named databases in my advancedsettings any more, but seeing as I have been using this for ages when it was required and I couldn't work out a way to rename or migrate my data from a db called xbmcvideos to myvideos I left the name as it was. If someone can tell me how to change the name of the db that would be cool.

Also I didn't leave the first attempt to connect to the db for very long, but the result is the same if I did - it just doesn't connect.
Openelec on ASRock ION 330 / Kodi on Win 7 PC
Reply
#3
Further Update

1. The problem has nothing to do with the drives in the server spinning up. The problem occurs if they are up or down.
2. If I set XBMC to hibernate after a period of inactivity using the Power Saving settings the connection to mySQL database is retained on waking from hibernation
3. If I set XBMC to suspend after a period of inactivity using the Power Saving settings the connection to mySQL database is lost on waking from suspend.
4. the shares on the server are visible from the htpc (i.e. the network is working)

To reiterate - this was not a problem using Eden, only after upgrading to Frodo.

II'm thinking more and more that this is just a peculiarity of my system, which would really suck as I was hoping that someone would be able to help me out.
Openelec on ASRock ION 330 / Kodi on Win 7 PC
Reply
#4
Had some further time to investigate and have found a bunch of other users with the same issue.

So for the sake of anyone stumbling across this check out these threads
Delay XMBC start when resuming from sleep
Frodo beta - Error loading mysql database on first boot
Frodo RC1/RC2 regression with mysql shared db
Automatic WakeOnLan upon accessing MySql or FileShares - which seems to have a promising patch which may soon be included in mainline. I haven't tried the build in the thred compiled by Kricker

Other suggestions to fix were to run Advanced WoL or a WoL script, which appear to be kind of working for me but needs more testing.
Openelec on ASRock ION 330 / Kodi on Win 7 PC
Reply
#5
I think I am having the same problem: After a periode of suspend XBMC cant connect to the MySQL server on after wake up. You didnt find a solution for this in the meantime, no?

In the logfile you posted you are having the problem even with a clean boot (not after waking up from suspend)?
Reply
#6
I am pretty sure the problem (at least in my case) is that the network interface is not up yet when XBMC resumes and tries to access the database. I patched XBMC to wait for the network interface to be up after waking up.

You may want to give it a try:
https://dl.dropboxusercontent.com/u/2464...ql_fix.zip

You need to put this setting to your advancedsettings.xml:
Code:
    <suspend>
        <waitfornetafterwakup>1</waitfornetafterwakup>
    </suspend>

When enabled you shut see something like this in the debug log:
Code:
21:40:50 T:140548965910336  NOTICE: OnWake: Running resume jobs
21:40:50 T:140548965910336   DEBUG: WaitForNet: Waithing for first NIC to come up
...
21:40:51 T:140548965910336   DEBUG: WaitForNet: NIC is up after waiting 400 ms

So in my case XBMC delayed the resume by 400 ms to let the NIC come up. Mysql is immediately available then. If someone could help testing it would be awesome.

Here is the source btw:
https://github.com/verybadsoldier/xbmc/t...ter-wakeup
Reply
#7
Hey devkid, I'd like to try this as I'm having the same problem on my Windows box but the file you posted on Dropbox doesn't appear to exist anymore. Would be very grateful if you could repost it! Smile
Reply
#8
Hm, was that a Windows binary I posted? I'm sorry I did not develop on Windows for some time now. I can only provide an OpenELEC 3.2.0 image with that patch applied: https://dl.dropboxusercontent.com/u/2464...uspend.tar
Reply
#9
I believe it was for Windows, yeah. Pity, I was using OpenElec for a good 6 months to a year with a completely different sleep related issue (XBMC lockup, needing a script to kill and restart it when waking) and was pleased when my switch to Windows solved that particular issue! Alas, this one seems worse!

Just a thought: It's been less than 6 months since you posted that link. It might still be available in Dropbox's deleted file archive, or if not then their support might be able to recover it. Smile

Edit: Never mind. I managed to elegantly work around the issue using a scheduled task. Have posted my solution here: http://forum.xbmc.org/showthread.php?tid...pid1512525
Reply

Logout Mark Read Team Forum Stats Members Help
waking from sleep and unable to connect to mySQL0