Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a3f695e

Browse files
pg_upgrade: include additional detail in cluster check
When the cluster failed the pg_controldata check for clean shut down we only reported that it did so, not why. The state of the cluster can be important information when diagnosing the failed upgrade attempt, so instead include it in the error message. Discussion: https://postgr.es/m/E0D5EA16-A085-4753-8DDC-C7055048B439@yesql.se
1 parent 3c152a2 commit a3f695e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/bin/pg_upgrade/controldata.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
149149
* the server was shut down cleanly, from the controldata
150150
* perspective.
151151
*/
152-
/* remove leading spaces */
152+
/* Remove trailing newline and leading spaces */
153+
(void) pg_strip_crlf(p);
153154
while (*p == ' ')
154155
p++;
155-
if (strcmp(p, "shut down in recovery\n") == 0)
156+
if (strcmp(p, "shut down in recovery") == 0)
156157
{
157158
if (cluster == &old_cluster)
158159
pg_fatal("The source cluster was shut down while in recovery mode. To upgrade, use \"rsync\" as documented or shut it down as a primary.");
159160
else
160161
pg_fatal("The target cluster was shut down while in recovery mode. To upgrade, use \"rsync\" as documented or shut it down as a primary.");
161162
}
162-
else if (strcmp(p, "shut down\n") != 0)
163+
else if (strcmp(p, "shut down") != 0)
163164
{
164165
if (cluster == &old_cluster)
165-
pg_fatal("The source cluster was not shut down cleanly.");
166+
pg_fatal("The source cluster was not shut down cleanly, state reported as: \"%s\"", p);
166167
else
167-
pg_fatal("The target cluster was not shut down cleanly.");
168+
pg_fatal("The target cluster was not shut down cleanly, state reported as: \"%s\"", p);
168169
}
169170
got_cluster_state = true;
170171
}

0 commit comments

Comments
 (0)