diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-02-08 18:43:11 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-02-08 18:43:11 -0500 |
commit | 3971f64843b02e4a55d854156bd53e46a0588e45 (patch) | |
tree | 173c8cb46e8bedec34779f90551852bef47fc2ee /src/backend/utils/init/miscinit.c | |
parent | 0231f838565d2921a0960407c4240237ba1d56ae (diff) | |
download | postgresql-3971f64843b02e4a55d854156bd53e46a0588e45.tar.gz postgresql-3971f64843b02e4a55d854156bd53e46a0588e45.zip |
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/backend/utils/init/miscinit.c')
-rw-r--r-- | src/backend/utils/init/miscinit.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index b7bab56099f..03cbb6e3499 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -691,6 +691,31 @@ GetUserNameFromId(Oid roleid, bool noerr) return result; } +/* + * Quick hack. + */ +const char * +current_time_as_str(void) +{ + static char buf[128]; + struct timeval now_timeval; + pg_time_t now; + char msbuf[8]; + + gettimeofday(&now_timeval, NULL); + now = (pg_time_t) now_timeval.tv_sec; + + pg_strftime(buf, sizeof(buf), + /* leave room for milliseconds... */ + "%Y-%m-%d %H:%M:%S %Z", + pg_localtime(&now, log_timezone)); + + /* 'paste' milliseconds into place... */ + sprintf(msbuf, ".%03d", (int) (now_timeval.tv_usec / 1000)); + memcpy(buf + 19, msbuf, 4); + + return buf; +} /*------------------------------------------------------------------------- * Interlock-file support @@ -724,6 +749,9 @@ UnlinkLockFiles(int status, Datum arg) } /* Since we're about to exit, no need to reclaim storage */ lock_files = NIL; + + if (IsPostmasterEnvironment) + elog(LOG, "lock files all released at %s", current_time_as_str()); } /* |