1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

pg_upgrade: detect stale postmaster.pid lock files

If the postmaster.pid lock file exists, try starting/stopping the
cluster to check if the lock file is valid.

Per request from Tom.
This commit is contained in:
Bruce Momjian
2013-01-24 15:20:11 -05:00
parent 74ebba84ae
commit a9ceaa53be
5 changed files with 54 additions and 30 deletions

View File

@ -170,8 +170,8 @@ stop_postmaster_atexit(void)
}
void
start_postmaster(ClusterInfo *cluster)
bool
start_postmaster(ClusterInfo *cluster, bool throw_error)
{
char cmd[MAXPGPATH * 4 + 1000];
PGconn *conn;
@ -236,6 +236,9 @@ start_postmaster(ClusterInfo *cluster)
false,
"%s", cmd);
if (!pg_ctl_return && !throw_error)
return false;
/* Check to see if we can connect to the server; if not, report it. */
if ((conn = get_db_conn(cluster, "template1")) == NULL ||
PQstatus(conn) != CONNECTION_OK)
@ -256,6 +259,8 @@ start_postmaster(ClusterInfo *cluster)
CLUSTER_NAME(cluster));
os_info.running_cluster = cluster;
return true;
}