Skip to content

Commit 8d20831

Browse files
bmdoilmy-ship-it
authored andcommitted
pg_upgrade: Fix core dump in report_progress()
The report_progress function may take a NULL argument for cluster, but was not checking it before trying to print cluster->major_version_str, resulting in a core dump. Add a check before fprintf call, which also resolves a FIXME. Also use --progress flag in pg_upgrade regression test. Authored-by: Brent Doil <[email protected]>
1 parent 5c173c6 commit 8d20831

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/bin/pg_upgrade/greenplum/reporting.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,15 @@ report_progress(ClusterInfo *cluster, progress_type op, char *fmt,...)
9494
}
9595

9696
/*
97-
* GPDB_12_MERGE_FIXME: The CLUSTER_NAME macro was removed, so we've
98-
* changed to printing the major version of the cluster instead. This may
99-
* well be good enough (or even better), but some more thought should go
100-
* into this before calling it done.
97+
* In the case where cluster is NULL, omit the cluster version in
98+
* the progress file.
10199
*/
102-
fprintf(progress_file, "%lu;%s;%s;%s;\n",
103-
epoch_us(), cluster->major_version_str, opname(op), message);
100+
if (cluster && *cluster->major_version_str != '\0')
101+
fprintf(progress_file, "%lu;%s;%s;%s;\n",
102+
epoch_us(), cluster->major_version_str, opname(op), message);
103+
else
104+
fprintf(progress_file, "%lu;%s;%s;\n", epoch_us(), opname(op), message);
105+
104106
progress_counter++;
105107

106108
/*

src/bin/pg_upgrade/test_gpdb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ upgrade_qd()
172172

173173
# Run pg_upgrade
174174
pushd $1
175-
time ${NEW_BINDIR}/pg_upgrade --mode=dispatcher --old-bindir=${OLD_BINDIR} --old-datadir=$2 --new-bindir=${NEW_BINDIR} --new-datadir=$3 ${PGUPGRADE_OPTS}
175+
time ${NEW_BINDIR}/pg_upgrade --mode=dispatcher --progress --old-bindir=${OLD_BINDIR} --old-datadir=$2 --new-bindir=${NEW_BINDIR} --new-datadir=$3 ${PGUPGRADE_OPTS}
176176
if (( $? )) ; then
177177
echo "ERROR: Failure encountered in upgrading qd node"
178178
exit 1

0 commit comments

Comments
 (0)