postgresql/src/bin
Tom Lane 6bcce25801 Fix "pg_ctl start -w" to test child process status directly.
pg_ctl start with -w previously relied on a heuristic that the postmaster
would surely always manage to create postmaster.pid within five seconds.
Unfortunately, that fails much more often than we would like on some of the
slower, more heavily loaded buildfarm members.

We have known for quite some time that we could remove the need for that
heuristic on Unix by using fork/exec instead of system() to launch the
postmaster.  This allows us to know the exact PID of the postmaster, which
allows near-certain verification that the postmaster.pid file is the one
we want and not a leftover, and it also lets us use waitpid() to detect
reliably whether the child postmaster has exited or not.

What was blocking this change was not wanting to rewrite the Windows
version of start_postmaster() to avoid use of CMD.EXE.  That's doable
in theory but would require fooling about with stdout/stderr redirection,
and getting the handling of quote-containing postmaster switches to
stay the same might be rather ticklish.  However, we realized that
we don't have to do that to fix the problem, because we can test
whether the shell process has exited as a proxy for whether the
postmaster is still alive.  That doesn't allow an exact check of the
PID in postmaster.pid, but we're no worse off than before in that
respect; and we do get to get rid of the heuristic about how long the
postmaster might take to create postmaster.pid.

On Unix, this change means that a second "pg_ctl start -w" immediately
after another such command will now reliably fail, whereas previously
it would succeed if done within two seconds of the earlier command.
Since that's a saner behavior anyway, it's fine.  On Windows, the case can
still succeed within the same time window, since pg_ctl can't tell that the
earlier postmaster's postmaster.pid isn't the pidfile it is looking for.
To ensure stable test results on Windows, we can insert a short sleep into
the test script for pg_ctl, ensuring that the existing pidfile looks stale.
This hack can be removed if we ever do rewrite start_postmaster(), but that
no longer seems like a high-priority thing to do.

Back-patch to all supported versions, both because the current behavior
is buggy and because we must do that if we want the buildfarm failures
to go away.

Tom Lane and Michael Paquier
2015-10-12 18:30:36 -04:00
..
initdb Translation updates 2015-06-28 23:56:55 -04:00
pg_archivecleanup Make WAL-related utilities handle .partial WAL files properly. 2015-07-03 11:53:58 +09:00
pg_basebackup Review program help output for wording and formatting 2015-09-16 00:59:28 -04:00
pg_config Translation updates 2015-06-28 23:56:55 -04:00
pg_controldata Make pg_controldata report newest XID with valid commit timestamp 2015-09-24 23:31:17 +09:00
pg_ctl Fix "pg_ctl start -w" to test child process status directly. 2015-10-12 18:30:36 -04:00
pg_dump ALTER TABLE .. FORCE ROW LEVEL SECURITY 2015-10-04 21:05:08 -04:00
pg_resetxlog Make pg_controldata report newest XID with valid commit timestamp 2015-09-24 23:31:17 +09:00
pg_rewind pg_rewind: Improve some messages 2015-10-01 21:42:00 -04:00
pg_test_fsync Move pg_test_fsync from contrib/ to src/bin/ 2015-04-19 22:20:49 -04:00
pg_test_timing Move pg_test_timing from contrib/ to src/bin/ 2015-04-20 21:30:12 -04:00
pg_upgrade Honour TEMP_CONFIG when testing pg_upgrade 2015-09-17 11:57:00 -04:00
pg_xlogdump Improve includes introduced in the replication origins patch. 2015-08-06 12:41:46 +02:00
pgbench Fix incorrect tps number calculation in "excluding connections establishing". 2015-09-30 10:53:31 +09:00
pgevent Update copyright for 2015 2015-01-06 11:43:47 -05:00
psql psql: allow \pset C in setting the title, matches \C 2015-10-05 20:56:38 -04:00
scripts reindexdb: Fix mistake in help output 2015-09-27 11:22:16 -04:00
Makefile Move pg_xlogdump from contrib/ to src/bin/ 2015-04-21 19:03:49 -04:00