summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorTom Lane2016-02-08 23:43:11 +0000
committerTom Lane2016-02-08 23:43:11 +0000
commit3971f64843b02e4a55d854156bd53e46a0588e45 (patch)
tree173c8cb46e8bedec34779f90551852bef47fc2ee /src/bin
parent0231f838565d2921a0960407c4240237ba1d56ae (diff)
Temporarily make pg_ctl and server shutdown a whole lot chattier.
This is a quick hack, due to be reverted when its purpose has been served, to try to gather information about why some of the buildfarm critters regularly fail with "postmaster does not shut down" complaints. Maybe they are just really overloaded, but maybe something else is going on. Hence, instrument pg_ctl to print the current time when it starts waiting for postmaster shutdown and when it gives up, and add a lot of logging of the current time in the server's checkpoint and shutdown code paths. No attempt has been made to make this pretty. I'm not even totally sure if it will build on Windows, but we'll soon find out.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_ctl/pg_ctl.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 9da38c4e6f0..c970a733801 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -946,6 +946,32 @@ do_start(void)
}
+/*
+ * Quick hack.
+ */
+const char *
+current_time_as_str(void)
+{
+ static char buf[128];
+ struct timeval now_timeval;
+ time_t now;
+ char msbuf[8];
+
+ gettimeofday(&now_timeval, NULL);
+ now = (time_t) now_timeval.tv_sec;
+
+ strftime(buf, sizeof(buf),
+ /* leave room for milliseconds... */
+ "%Y-%m-%d %H:%M:%S %Z",
+ localtime(&now));
+
+ /* 'paste' milliseconds into place... */
+ sprintf(msbuf, ".%03d", (int) (now_timeval.tv_usec / 1000));
+ memcpy(buf + 19, msbuf, 4);
+
+ return buf;
+}
+
static void
do_stop(void)
{
@@ -998,7 +1024,12 @@ do_stop(void)
"Shutdown will not complete until pg_stop_backup() is called.\n\n"));
}
- print_msg(_("waiting for server to shut down..."));
+ if (!silent_mode)
+ {
+ fprintf(stdout, _("waiting for server to shut down at %s..."),
+ current_time_as_str());
+ fflush(stdout);
+ }
for (cnt = 0; cnt < wait_seconds; cnt++)
{
@@ -1015,7 +1046,8 @@ do_stop(void)
{
print_msg(_(" failed\n"));
- write_stderr(_("%s: server does not shut down\n"), progname);
+ write_stderr(_("%s: server does not shut down at %s\n"),
+ progname, current_time_as_str());
if (shutdown_mode == SMART_MODE)
write_stderr(_("HINT: The \"-m fast\" option immediately disconnects sessions rather than\n"
"waiting for session-initiated disconnection.\n"));