I'm writing a small test harness. I have two threads. One that starts
the postmaster and another that does all the testing and finally stops
the postmaster with a pg_ctl stop. At present, the second thread starts
with a sleep sufficient to ensure that the postmaster is running. Is
there a proper way to test when the postmaster is ready to receive commands?
Kind regards,
Thomas Hallgren 8 1702
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday 10 June 2004 09:10, Thomas Hallgren wrote: I'm writing a small test harness. I have two threads. One that starts the postmaster and another that does all the testing and finally stops the postmaster with a pg_ctl stop. At present, the second thread starts with a sleep sufficient to ensure that the postmaster is running. Is there a proper way to test when the postmaster is ready to receive commands?
postmaster will not send a signal on its own,
but you can do some kind of busy polling:
# untested bash script
count=0
while true
do
if psql -c '\q' $MY_DATABASE 2>/dev/null
then
break
fi
count=$(($count + 1))
if [ $count > 10 ]
then
echo "Postgres seems not to be working" >&2
exit 1
fi
sleep 1
done
psql $MY_DATABASE
Mit freundlichem Gruß / With kind regards
Holger Klawitter
- --
lists <at> klawitter <dot> de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQFAyBlE1Xdt0HKSwgYRAtoKAJ9uWwaSQPyFae+q7bZFP6 ovDRcTgwCcD2Dl
FdpLC9FtMsZ7PZtGqfW843g=
=BHoK
-----END PGP SIGNATURE-----
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday 10 June 2004 09:10, Thomas Hallgren wrote: I'm writing a small test harness. I have two threads. One that starts the postmaster and another that does all the testing and finally stops the postmaster with a pg_ctl stop. At present, the second thread starts with a sleep sufficient to ensure that the postmaster is running. Is there a proper way to test when the postmaster is ready to receive commands?
postmaster will not send a signal on its own,
but you can do some kind of busy polling:
# untested bash script
count=0
while true
do
if psql -c '\q' $MY_DATABASE 2>/dev/null
then
break
fi
count=$(($count + 1))
if [ $count > 10 ]
then
echo "Postgres seems not to be working" >&2
exit 1
fi
sleep 1
done
psql $MY_DATABASE
Mit freundlichem Gruß / With kind regards
Holger Klawitter
- --
lists <at> klawitter <dot> de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQFAyBlE1Xdt0HKSwgYRAtoKAJ9uWwaSQPyFae+q7bZFP6 ovDRcTgwCcD2Dl
FdpLC9FtMsZ7PZtGqfW843g=
=BHoK
-----END PGP SIGNATURE-----
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org
Thomas Hallgren wrote: I'm writing a small test harness. I have two threads. One that starts the postmaster and another that does all the testing and finally stops the postmaster with a pg_ctl stop. At present, the second thread starts with a sleep sufficient to ensure that the postmaster is running. Is there a proper way to test when the postmaster is ready to receive commands?
I've always assumed once I can connect, then I can send queries. There's
certainly a "postmaster still starting up" error message I've seen,
which would support that view.
--
Richard Huxton
Archonet Ltd
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Thomas Hallgren wrote: I'm writing a small test harness. I have two threads. One that starts the postmaster and another that does all the testing and finally stops the postmaster with a pg_ctl stop. At present, the second thread starts with a sleep sufficient to ensure that the postmaster is running. Is there a proper way to test when the postmaster is ready to receive commands?
I've always assumed once I can connect, then I can send queries. There's
certainly a "postmaster still starting up" error message I've seen,
which would support that view.
--
Richard Huxton
Archonet Ltd
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Thomas Hallgren <th***@mailblocks.com> writes: I'm writing a small test harness. I have two threads. One that starts the postmaster and another that does all the testing and finally stops the postmaster with a pg_ctl stop. At present, the second thread starts with a sleep sufficient to ensure that the postmaster is running. Is there a proper way to test when the postmaster is ready to receive commands?
Check to see if it answers a connection request. If you look in the
archives for discussion of a "pg_ping" utility you'll find more about
this. My recollection is that we'd tweaked the postmaster's behavior
so that a useful pg_ping could be written (in particular, that you'd
not need to know a valid database/user name to check for postmaster
ready), but then no one got round to actually writing it.
Now that pg_ctl is in C, it would likely make sense to rewrite its
postmaster probing as per the pg_ping ideas instead of trying to open
a normal connection.
(As for your test harness, though, you could just use pg_ctl start
with the wait option, and wait for it to finish...)
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
Thomas Hallgren <th***@mailblocks.com> writes: I'm writing a small test harness. I have two threads. One that starts the postmaster and another that does all the testing and finally stops the postmaster with a pg_ctl stop. At present, the second thread starts with a sleep sufficient to ensure that the postmaster is running. Is there a proper way to test when the postmaster is ready to receive commands?
Check to see if it answers a connection request. If you look in the
archives for discussion of a "pg_ping" utility you'll find more about
this. My recollection is that we'd tweaked the postmaster's behavior
so that a useful pg_ping could be written (in particular, that you'd
not need to know a valid database/user name to check for postmaster
ready), but then no one got round to actually writing it.
Now that pg_ctl is in C, it would likely make sense to rewrite its
postmaster probing as per the pg_ping ideas instead of trying to open
a normal connection.
(As for your test harness, though, you could just use pg_ctl start
with the wait option, and wait for it to finish...)
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
Tom Lane wrote: Thomas Hallgren <th***@mailblocks.com> writes:
I'm writing a small test harness. I have two threads. One that starts the postmaster and another that does all the testing and finally stops the postmaster with a pg_ctl stop. At present, the second thread starts with a sleep sufficient to ensure that the postmaster is running. Is there a proper way to test when the postmaster is ready to receive commands?
Check to see if it answers a connection request. If you look in the archives for discussion of a "pg_ping" utility you'll find more about this. My recollection is that we'd tweaked the postmaster's behavior so that a useful pg_ping could be written (in particular, that you'd not need to know a valid database/user name to check for postmaster ready), but then no one got round to actually writing it.
Now that pg_ctl is in C, it would likely make sense to rewrite its postmaster probing as per the pg_ping ideas instead of trying to open a normal connection.
(As for your test harness, though, you could just use pg_ctl start with the wait option, and wait for it to finish...)
regards, tom lane
Thanks (to all who replied). I think have what I need to make good progress.
(I did try using pg_ctl start but I encountered several problems on
win32 when attempting to pass -c options to the postmaster. Seems to be
some problem concerning who parses what, the shell or pg_ctl (windows is
utterly stupid when it comes to command line parsing). And using the
wait option seemed to wait forever on win32. I'm still investigating,
will get back to you if I find something relevant).
Kind regards,
Thomas Hallgren
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
Tom Lane wrote: Thomas Hallgren <th***@mailblocks.com> writes:
I'm writing a small test harness. I have two threads. One that starts the postmaster and another that does all the testing and finally stops the postmaster with a pg_ctl stop. At present, the second thread starts with a sleep sufficient to ensure that the postmaster is running. Is there a proper way to test when the postmaster is ready to receive commands?
Check to see if it answers a connection request. If you look in the archives for discussion of a "pg_ping" utility you'll find more about this. My recollection is that we'd tweaked the postmaster's behavior so that a useful pg_ping could be written (in particular, that you'd not need to know a valid database/user name to check for postmaster ready), but then no one got round to actually writing it.
Now that pg_ctl is in C, it would likely make sense to rewrite its postmaster probing as per the pg_ping ideas instead of trying to open a normal connection.
(As for your test harness, though, you could just use pg_ctl start with the wait option, and wait for it to finish...)
regards, tom lane
Thanks (to all who replied). I think have what I need to make good progress.
(I did try using pg_ctl start but I encountered several problems on
win32 when attempting to pass -c options to the postmaster. Seems to be
some problem concerning who parses what, the shell or pg_ctl (windows is
utterly stupid when it comes to command line parsing). And using the
wait option seemed to wait forever on win32. I'm still investigating,
will get back to you if I find something relevant).
Kind regards,
Thomas Hallgren
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike |
last post by:
Hi,
In my web form, which registers email addresses, my php script does
some email validation, but people still mistype email addresses which
are in a valid format but don't exist.
PHP tries to...
|
by: Chris Webster |
last post by:
I have one process which writes a single float into 300 columns once per
second. I then run 4 process, from remote computers, to query a small
subset of the latest row.
I have even commented...
|
by: psql-mail |
last post by:
Help!
Postmaster is segfaulting i think.
I am running RH_AS_3beta, postgresql 7.3.4 compiled from postgresql-7.3.
4-1PGDG.src.rpm on ia64 arch.
Tsearch2 compiled from tsearch-v2-stable.tar.gz
...
|
by: Andy Harrison |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Could anyone explain about the max_connections in postgres?
We ran into the connection limit on one of our production servers. One reason
is that we have...
|
by: Jeremiah Elliott |
last post by:
I have a java application that pulls data off db2/400 an inserts it into a
postgres(7.3.2) database. The jdbc errors out with this message:
ConnectionBean: Driver not loaded Something unusual has...
| |
by: wespvp |
last post by:
I've got a 2 hour index build that has been running for 9 hours. With 'ps
-efl' I see that there is a VACUUM ANALYZE running that started 24 hours ago
and my index build is 'wating'. I sent a...
|
by: Thomas Hallgren |
last post by:
I'm writing a small test harness. I have two threads. One that starts
the postmaster and another that does all the testing and finally stops
the postmaster with a pg_ctl stop. At present, the...
|
by: Tony O'Bryan |
last post by:
I am normally the admin for our PostgreSQL servers, but someone else tried
to kill a runaway query while I was out sick. Unfortunately, he tried
killing the runaway query by killing the...
|
by: Tomás |
last post by:
When you simply want to store a number, what integral type do you use?
For instance, let's say we have the following in a Poker game:
struct Card
{
enum Suit { Hearts, Diamonds, Spades, Clubs...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |