mythbuntu starts frontend to fast
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mythtv (Ubuntu) |
Confirmed
|
Medium
|
Unassigned | ||
Bug Description
Binary package hint: mythbuntu-common
I upgraded mythbuntu to 9.10. Now when I boot, mythwelcome is unable to connect to mysql and comes with a setup dialog. (first screen is choosing the language.) Starting mythwelcome or mythfrontend manually from a terminal works fine, since at that point mysql and mythtv-backend have started.
I tried delaying the start of mythwelcome in /usr/share/
My suspicion is that mythwelcome/
If any other information is needed, please let me know.
Bert Haverkamp
P.S. possibly mythbuntu-common is not the appropriate package, but it is definitely a mythbuntu setup problem.
Mario Limonciello (superm1) wrote : | #1 |
Changed in mythbuntu-common (Ubuntu): | |
status: | New → Incomplete |
affects: | mythbuntu-common (Ubuntu) → mythtv (Ubuntu) |
WeatherGod (ben-v-root) wrote : | #2 |
I am not exactly familiar with how Ubuntu's Upstart works, but couldn't you just set the mysql and mythtv-backend to start before some of the other services?
brjhaverkamp (bert-bertenselena) wrote : Re: [Bug 470672] Re: mythbuntu starts frontend to fast | #3 |
On Mon, Nov 2, 2009 at 4:23 PM, Mario Limonciello <email address hidden> wrote:
> So you did a dist-upgrade from 9.04, correct?
>
> Can you try to elaborate on how you've customized the box and how you
> set up mythwelcome to start?
Indeed, I did a dist-upgrade last week. I was running 9.04 and
upgraded to 9.10. All went well with regards to mythv. (I have some
other problems, but alas.
To start mythwelcome I added MYTHWELCOME=true in
/etc/mythtv/
mythbuntu, right (correct me if I'm wrong here)
brjhaverkamp (bert-bertenselena) wrote : | #4 |
On Mon, Nov 2, 2009 at 5:04 PM, WeatherGod <email address hidden> wrote:
> I am not exactly familiar with how Ubuntu's Upstart works, but couldn't
> you just set the mysql and mythtv-backend to start before some of the
> other services?
Indeed, I asume the problem is due to a different timing because of
upstart. But I'm also not familiar with it. Also, mythwelcome is not
started by upstart, so you can only control half of the problem from
within upstart. As there is currently no guarantee that everything is
started by the time mythwelcome needs it, I reported this bug.
Mario Limonciello (superm1) wrote : | #5 |
Well two things.
1) Mysql wasn't converted to an upstart service, so there is a race
condition with the backend and mysql. The backend figures it out though,
and just has a few failed connection attempts on every boot
2) You can't set dependencies on graphical userspace things like
mythwelcome. In most scenarios though, gdm will start FAR later than
mythbackend does, so it's surprising this is coming up and why I'm wondering
if there is anything special that was done to this install to cause such a
race condition.
It's possible that this is just ungodly fast hardware too, what are the
hardware specs? Are you booting from something like an SSD?
On Mon, Nov 2, 2009 at 10:04, WeatherGod <email address hidden> wrote:
> I am not exactly familiar with how Ubuntu's Upstart works, but couldn't
> you just set the mysql and mythtv-backend to start before some of the
> other services?
>
> --
> mythbuntu starts frontend to fast
> https:/
> You received this bug notification because you are a member of Mythbuntu
> Bug Team, which is subscribed to mythtv in ubuntu.
>
--
Mario Limonciello
<email address hidden>
brjhaverkamp (bert-bertenselena) wrote : | #6 |
On Mon, Nov 2, 2009 at 6:44 PM, Mario Limonciello <email address hidden> wrote:
> Well two things.
> 1) Mysql wasn't converted to an upstart service, so there is a race
> condition with the backend and mysql. The backend figures it out though,
Thanks for this. I didn't realize. But if the backend depends on
mysql, why not (for the moment) build in a delay untill mysql is
started?
(this snipped I added to /usr/share/
delay=30
while [ ! -e "/var/run/
let delay--
sleep 1
echo "No database yet , sleeping for $delay seconds" | tee -a
$MYTHWELCOMELOG
done
> and just has a few failed connection attempts on every boot
> 2) You can't set dependencies on graphical userspace things like
> mythwelcome. In most scenarios though, gdm will start FAR later than
> mythbackend does, so it's surprising this is coming up and why I'm wondering
> if there is anything special that was done to this install to cause such a
> race condition.
>
> It's possible that this is just ungodly fast hardware too, what are the
> hardware specs? Are you booting from something like an SSD?
I wish:-) No it is an ordinary dual core E7400 with an even more ordinary HD..
But from the logs I see that they start about the same time.
Would it be possible to build a check for the mythbackend proces and
lirc daemon in mythfrontend.sh, like I did above with mysql?
Would that solve the race?
Bert
> On Mon, Nov 2, 2009 at 10:04, WeatherGod <email address hidden> wrote:
>
>> I am not exactly familiar with how Ubuntu's Upstart works, but couldn't
>> you just set the mysql and mythtv-backend to start before some of the
>> other services?
>>
>> --
>> mythbuntu starts frontend to fast
>> https:/
>> You received this bug notification because you are a member of Mythbuntu
>> Bug Team, which is subscribed to mythtv in ubuntu.
>>
>
>
> --
> Mario Limonciello
> <email address hidden>
>
> --
> mythbuntu starts frontend to fast
> https:/
> You received this bug notification because you are a direct subscriber
> of the bug.
>
--
-------
38 is NOT a random number!!!!
schaze (schaze) wrote : | #7 |
Hi Guys,
I have exaclty the same problem. I did a clean install however.
I do have a SSD (booting quickly like hell :)) ) disk so it really seems to be a timing issue.
I will try the code snippet suggested by bert and report back.
But there should be bugfix for this as it practically makes my MythBox unusable.
/Schaze
schaze (schaze) wrote : | #8 |
the little while loop works great. (the let delay-- however does not seem to work but thats no problem)
What do you think will it be realistic that mysql will be converted to upstart any soon (within 9.10)?
/schaze
brjhaverkamp (bert-bertenselena) wrote : | #9 |
I don't have ssd unfortunately, but for some reason mythbackend starts
late on my config.
Meanwhile I have been digging into my system to try and cure this.
I have added the following to /usr/share /mythtv/
(replace the logfile with whatever you like.)
LOGFILE=
LOGENTRY="$(date +"%b %d %T") Mythfrontend.sh:"
echo $LOGENTRY "Are mysql, mythbackend and lirc runnning" | tee -a $LOGFILE
delay=30
while [ ! "$(pidof mysqld)" ] && [ "$delay" -gt "0" ]; do
let delay--
sleep 1
echo $LOGENTRY No mysqld yet. Delay: $delay | tee -a $LOGFILE
done
if [ "$(pidof mysqld)" ]; then
echo $LOGENTRY mysqld started. pid is $(pidof mysqld) | tee -a $LOGFILE
fi
while [ -z "$(pidof mythbackend)" ] && [ "$delay" -gt "0" ]; do
let delay--
sleep 1
echo $LOGENTRY No mythbackend yet. Delay: $delay | tee -a $LOGFILE
done
if [ "$(pidof mythbackend)" ]; then
echo $LOGENTRY mythbackend started. pid is $(pidof
mythbackend) | tee -a $LOGFILE
fi
while [ ! "$(pidof lircd)" ] && [ "$delay" -gt "0" ]; do
let delay--
sleep 1
echo $LOGENTRY No lircd yet. Delay: $delay | tee -a $LOGFILE
done
if [ "$(pidof lircd)" ]; then
echo $LOGENTRY lircd started. pid is $(pidof lircd) | tee -a $LOGFILE
fi
The following is from the winbox.log at startup at 1:00 at night (for
getting the EPG)
Nov 16 01:00:51 Startdvb: Winebox starting up.
Nov 16 01:00:54 Mythfrontend.sh: Are mysql, mythbackend and lirc runnning
Nov 16 01:00:54 Mythfrontend.sh: No mysqld yet. Delay: 30
Nov 16 01:00:54 Mythfrontend.sh: No mysqld yet. Delay: 29
Nov 16 01:00:54 Mythfrontend.sh: No mysqld yet. Delay: 28
Nov 16 01:00:54 Mythfrontend.sh: No mysqld yet. Delay: 27
Nov 16 01:00:54 Mythfrontend.sh: No mysqld yet. Delay: 26
Nov 16 01:00:54 Mythfrontend.sh: No mysqld yet. Delay: 25
Nov 16 01:00:54 Mythfrontend.sh: No mysqld yet. Delay: 24
Nov 16 01:00:54 Mythfrontend.sh: mysqld started. pid is 2506
Nov 16 01:00:54 Mythfrontend.sh: mythbackend started. pid is 2525
Nov 16 01:00:54 Mythfrontend.sh: No lircd yet. Delay: 23
Nov 16 01:00:54 Mythfrontend.sh: No lircd yet. Delay: 22
Nov 16 01:00:54 Mythfrontend.sh: No lircd yet. Delay: 21
Nov 16 01:00:54 Mythfrontend.sh: lircd started. pid is 2892
Nov 16 01:30:30 Setwakeup: Setting wake-up time to Mon Nov 16 20:45:00 CET 2009
Still I get an error that the backend is not found in either
mythwelcome or mythfrontend (they start close after eachother and I
can't be certain who gives the error).
The error disappears quickly and the system works from then on.
From mythwelcome.log I have:
2009-11-16 01:01:04.705 Using runtime prefix = /usr
2009-11-16 01:01:04.705 Using configuration directory = /home/mythuser/
2009-11-16 01:01:04.706 Empty LocalHostName.
2009-11-16 01:01:04.706 Using localhost value of winebox
2009-11-16 01:01:04.706 Configuration::Load - Error parsing:
/home/mythuser/
umn: 1
2009-11-16 01:01:04.706 Configuration::Load - Error Msg: unexpected end of file
2009-11-16 01:01:04.709 New DB connection, total: 1
2009-11-16 01:01:04.711 Connected to database 'm...
schaze (schaze) wrote : | #10 |
Hi Guys,
I have another (ugly) solution for this problem now...
To describe my scenario and make my solution perhaps use full for others:
I have the following programs that need to be started:
1. mysql (daemon)
2. mythtv-backend (daemon)
3. mythfrontend (application started via autostart in xfce)
Problem:
mysql --> still an old init script
mythtv-backend --> converted to upstart job
When my PC boot the following happens:
mythtv-backend is started very early and tries to connect to mysql, which is not possble as the remaining old init scripts seem to be started after all the upstart jobs. This is no problem as mythtv-backend simply retries to connect until the mysql db is up.
But as GDM was also converted to upstart the userinterface (xfce) is started already before the init scripts are started and so does then the mythfrontend via autostart. As the mythfrontend needs a connection to both, mysql and myth-backend it fails to start properly as it cannot connect to the DB. unlike the backend the frontend does not start to reconnect several times and so I am stuck, as this is thought to be a htpc to watch television and movies in the living room without keyboard and mouse, only IR remote.
I hope this explains the problem.
One solution is to change the script that starts the mythfrontend and have it wait in a loop until the DB is up. This works fine, however it kills the whole effect of a fast boot on the new Ubuntu Karmic as I have to wait about 8-10 seconds after autologin to xfce for the DB.
My second solution I now did is quite simple but also very ugly as it mixes the old init scripts with upstart.
I simply changed the mythtv-backend job in upstart and added to folowing pre-start script:
pre-start script
/etc/
end script
with this the DB is started before the mythtv-backend is started. and it is still done in parallel to any other potential upstart jobs and also before GDM is started. so my problem is solved.
As the mythtv-backend needs to be stopped for changing the base settings but the DB needs to be up I did not simply add mysql to a pre-stop script, but left the old init script for mysql also active. Now the following happens during boot and shutdown:
1. mythtv-backend job is beginning to start
1a. pre-start starts mysql
1b. after pre-start the real job is run and mythtv-backend is started
2. GDM starts
3. mythfrontend starts and can connect
4 between 2 and 3 the mysql init script runs and detects that mysql is already up and does nothing
on shutodwn the mysql database is simply stopped by the old initscript independand from the mythtv-backend.
I know this is not a very clean thing to do something but it work and it still has the benefit of a fast boot.
So my problem is solved for now. But I reall hope there will be a mysql upstart job to have this mess cleaned. This is a real design flaw and should not stay like that.
Thanks a lot for comments and help,
schaze
Changed in mythtv (Ubuntu): | |
importance: | Undecided → Medium |
status: | Incomplete → Triaged |
brjhaverkamp (bert-bertenselena) wrote : | #11 |
I finally had some time digging into the mail from Schaze
I don't even think it is that ugly. It is actually almost the right
way. When mysql is migrated to upstart, the "pre-start script" section
only needs to be moved to the "start on" section
I have extended Schaze's approach a bit though. In my
/etc/init/
pre-start script
/usr/
/etc/init.d/mysql start
/etc/init.d/lirc start
end script
This ensures that mysql and lirc are started and some local script to
setup my dvb-c cards.
I have also added a dependency from gdm to mythtv backed in /etc/init/gdm.conf:
start on (filesystem
and started hal
and started mythtv-backend
and tty-device-added KERNEL=tty7
and (graphics-
stop on runlevel [016]
This ensures that the backend is started when mythwelcome is started.
Regards,
Btw, Schaze, to make "let delay--" work you needed to make the script
a bash script (on the first line of the file edit it to #!/bin/bash.
But this is now history:-)
Garry Leach (garry-leach) wrote : | #12 |
I upgraded to Mythbuntu 9.10 from 9.04 on 07/02/2010. It all went well, except for the non auto-login (easily fixed) & the non-autostart of Myth frontend. I changed autostart, but then had the problem of myth frontend starting too fast, as described here.
Since both of these functions had been standard in earlier versions of Myth, I was somewhat surprised, & disappointed. As Schaze wrote on 2009-11-17, "This is a real design flaw and should not stay like that."
On the other hand, I am quite pleased with the improvements in Myth, so thanks for that (although it would have been nice to have an explanation for using "i" to find delete - but I like it now I know how).
I am basically an end-user, so am not sufficiently capable to understand the fixes proposed in this report by Schaze & brjhaverkamp. If this could be re-written in a way that I could see exactly what I need to do, I would very much appreciate that.
Regards, Garry.
schaze (schaze) wrote : | #13 |
Hey Guys,
I hope this is being fixed for lucid? There was no further comment since a loong time...
cheers,
schaze
figoza (figoza) wrote : | #14 |
hi schaze
sadly, this problem is still present on lucid.
ive recently installed mythtv on it and i found this problem too. it take a lot of time find some usefull info at blogs, until finally found this. but i have to confesse iam a newbie on ubuntu and i cant hardly understand where to find the files or make the scripts on it, so it would be great to see a little How-To in order to achieve the fix.
thanks a lot, in advance.
cheers
Thomas Mashos (tgm4883) wrote : | #15 |
A few issues with the changes proposed.
1) Not all frontends have a backend
2) Not all backends have a mysql server
Also hal isn't in lucid anymore
schaze (schaze) wrote : | #16 |
Hi figoza,
I assume you have a standard mythbuntu setup with backend, mysql and frontend on the the same machine.
as a quick fix you can for now simply do the following changes as a workaround:
open a terminal window
enter the following:
sudo nano /etc/init/
Change the line:
start on (local-filesystems and net-device-up IFACE=lo and started udev-finish)
To (add:and started mysql):
start on (local-filesystems and net-device-up IFACE=lo and started udev-finish and started mysql)
Save and exit editor
Then enter:
sudo nano /etc/init/gdm.conf
Change the start on block from:
start on (filesystem
and started dbus
and (graphics-
or drm-device-added card0 PRIMARY_
or stopped udevtrigger))
To (3rd line is new):
start on (filesystem
and started dbus
and started mythtv-backend
and (graphics-
or drm-device-added card0 PRIMARY_
or stopped udevtrigger))
Save and exit editor
With this your startup may appear slower by a few seconds as GDM only starts after mythtv-backend is started.
ATTENTION: in case mythtv-backend could not be started due to some reason you will _not_ get a graphical login screen!!
Hope this helps.
/schaze
P.S.: I used "nano" as editor as you mentioned beeing a newbie. You can of course use any other editor you like (e.g. vi :) )
schaze (schaze) wrote : | #17 |
@Thomas Mashos:
These are some very good points. I was only concentrated on my problem on my particular setup and did not think about the 'big picture'.
Hal is still in Lucid but not installed by default and deemed to be deprecated. I agree that a solution should better not be based on it.
To define it in detail the dependencies are the following:
- mysql-backend needs to wait for the related database before starting.
I believe at the moment mysql-backend tries several times (don't know for how long) to reach the database if it is started before the db is available. During this time I believe the backend-end is however not listening for incoming connections. So this is basically already working. However there should be a way for clients that try to connect to get aware of such a situation.
- the frontend should wait until the related backend is ready.
There is a start script and config file for mythfrontend already. It should be an easy thing to enhance this in order to wait for a backend to be ready.
One very basic solution I could think of would be to change the startscript for mythfrontend to do the following:
- try to connect to the database
- try to connect to the backend
- do the above steps for a configurable time or amounts with sleeps in between.
The connects for the backend could maybe be done by the use of the python bindings.
For the database: can mythtv run with another db than mysql - I believe not? if yes then its more complicated, if no, this could be included in the python script for the backend (if the python bindings not already also try to open a mysql connection in parallel)
I would really try to help solving this bug also by providing a script of any sort or doing an update to en existing one.
Please let me know who is responsible so we could agree on a solution and I can then (if this is wanted) provide the implementation.
cheers,
schaze
figoza (figoza) wrote : | #18 |
Hi Schaze
I use Ubuntu 10.04 Lucid Lynx with Myth TV 0.23 installed on it. Myth TV is setup with backend, mysql and frontend on the the same machine.
so i guess i can apply botherless the fix that you kindly advised.
Finally i could get the Myth Backend log and it looks like this:
2010-08-12 00:03:59.391 mythbackend version: branches/
[24158] www.mythtv.org
2010-08-12 00:03:59.834 Using runtime prefix = /usr
2010-08-12 00:03:59.855 Using configuration directory
= /home/mythtv/
2010-08-12 00:03:59.903 Empty LocalHostName.
2010-08-12 00:03:59.910 Using localhost value of figoza-desktop
2010-08-12 00:03:59.952 New DB connection, total: 1
2010-08-12 00:03:59.982 Connected to database 'mythconverg' at host:
localhost
2010-08-12 00:04:00.052 Closing DB connection named 'DBManager0'
2010-08-12 00:04:00.063 Connected to database 'mythconverg' at host:
localhost
2010-08-12 00:04:00.446 Current MythTV Schema Version (DBSchemaVer):
1254
2010-08-12 00:04:00.471 MythBackend: Starting up as the master server.
2010-08-12 00:04:00.508 New DB connection, total: 2
2010-08-12 00:04:00.613 Connected to database 'mythconverg' at host:
localhost
2010-08-12 00:04:00.686 Channel(
device, error "No such file or directory"
2010-08-12 00:04:00.777 MythBackend, Error: No valid capture cards are
defined in the database.
2010-08-12 00:04:00.852 New DB connection, total: 3
2010-08-12 00:04:00.894 Connected to database 'mythconverg' at host:
localhost
2010-08-12 00:04:00.909 MediaServer:: Loopback address specified -
127.0.0.1. Disabling UPnP
2010-08-12 00:04:00.918 Main::Registering HttpStatus Extension
2010-08-12 00:04:00.960 Enabled verbose msgs: important general
2010-08-12 00:04:01.024 AutoExpire: CalcParams(): Max required Free
Space: 1.0 GB w/freq: 15 min
2010-08-12 00:04:04.156 MainServer::ANN Monitor
2010-08-12 00:04:04.177 adding: figoza-desktop as a client (events: 0)
my TV card is a Kwolrd terminator Phillips 7134 chipset, iam sure the driver is correctly installed since i can see live tv on Myth TV (once i restart the backend) and i can see TV on TVtime.
It seems Myth Backend can connect on time with database but is unnable to start the TV Card. Am I Right?
Thanxs a lot in advance for your advice.
Figoza.
WeatherGod (ben-v-root) wrote : | #19 |
Figoza,
Thanks for confirming that the proposed fix works for you. As for your other problem, it would probably be best to file a new bug report dealing with the TV card.
Thank you for helping to make Ubuntu better!
tags: | added: patch-needswork |
ted munga (n2801841) wrote : | #20 |
Editing the /etc/init/
Changed in mythtv (Ubuntu): | |
status: | Triaged → Confirmed |
Brian Murray (brian-murray) wrote : | #21 |
This looks to be a duplicate of bug 609402.
So you did a dist-upgrade from 9.04, correct?
Can you try to elaborate on how you've customized the box and how you set up mythwelcome to start?