[PATCH] wait for db to become ready - WAS Re: [Ovirt-devel] Still having issues with the wui appliance install
Alan Pevec
apevec at redhat.com
Wed May 28 16:16:49 UTC 2008
Darryl L. Pierce wrote:
> I ran through it again and it's still not creating the ovirt database or
> role. After it finished the full installation and restarted, I watched
> it as it tried to bring up the ovirt system it complained that the
> postgres database was not initialized. When I got to a command prompt,
> went into Postgres and listed databases with \l I only saw postgres,
> template0 and template1 listed.
This turned out to be a timing issue in ovirt-wui-install during first boot, postgres was not ready immediately after 'service postgres start' returned.
PG initscript has optimistic sleep 2 after starting postmaster daemon but this wui VM was created w/o KVM support (VT was not enabled in BIOS) and running slooowly with qemu-system-x86_64
With KVM it's fast enough so this doesn't happen.
Here's the patch which should fix this: wait until we can connect to the database or timeout
diff --git a/wui/scripts/ovirt-wui-install b/wui/scripts/ovirt-wui-install
index 8d95d48..3891604 100755
--- a/wui/scripts/ovirt-wui-install
+++ b/wui/scripts/ovirt-wui-install
@@ -135,6 +135,21 @@ echo "host all all 127.0.0.1 255.255.255.0 trust" >> /var/lib/pgsql/data/pg_hba.
service postgresql stop > /dev/null 2>&1
service postgresql start
[ $? != 0 ] && echo "Failed to start database" && exit 1
+declare -i timeout=10
+while [[ timeout -gt 0 ]]
+do
+ sleep 2
+ psql -l -U postgres > /dev/null 2>&1
+ rc=$?
+ if [[ rc -eq 0 ]]
+ then
+ break
+ else
+ echo Database not ready yet, retrying...
+ fi
+ let timeout--
+done
+[[ timeout -eq 0 ]] && echo "Failed to start database" && exit 1
if [ -z $PASSWD ]; then
# generate random pg user password
More information about the ovirt-devel
mailing list