Skip to content

Commit d226e23

Browse files
committed
On Windows, have pg_upgrade use different two files to log pg_ctl
start/stop output, to fix file share error reported by Edmund Horner
1 parent 32cebaa commit d226e23

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

contrib/pg_upgrade/pg_upgrade.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ OSInfo os_info;
5858
char *output_files[] = {
5959
SERVER_LOG_FILE,
6060
#ifdef WIN32
61-
/* file is unique on Win32 */
62-
SERVER_LOG_FILE2,
61+
SERVER_START_LOG_FILE,
62+
SERVER_STOP_LOG_FILE,
6363
#endif
6464
RESTORE_LOG_FILE,
6565
UTILITY_LOG_FILE,

contrib/pg_upgrade/pg_upgrade.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,20 @@ extern char *output_files[];
5050
* because it is being used by another process." so send the pg_ctl
5151
* command-line output to a new file, rather than into the server log file.
5252
* Ideally we could use UTILITY_LOG_FILE for this, but some Windows platforms
53-
* keep the pg_ctl output file open even after pg_ctl exits, perhaps by the
54-
* running postmaster.
53+
* keep the pg_ctl output file open by the running postmaster, even after
54+
* pg_ctl exits.
5555
*
5656
* We could use the Windows pgwin32_open() flags to allow shared file
5757
* writes but is unclear how all other tools would use those flags, so
5858
* we just avoid it and log a little differently on Windows; we adjust
5959
* the error message appropriately.
6060
*/
6161
#ifndef WIN32
62-
#define SERVER_LOG_FILE2 SERVER_LOG_FILE
62+
#define SERVER_START_LOG_FILE SERVER_LOG_FILE
63+
#define SERVER_STOP_LOG_FILE SERVER_LOG_FILE
6364
#else
64-
#define SERVER_LOG_FILE2 "pg_upgrade_server2.log"
65+
#define SERVER_START_LOG_FILE "pg_upgrade_server_start.log"
66+
#define SERVER_STOP_LOG_FILE "pg_upgrade_server_stop.log"
6567
#endif
6668

6769

contrib/pg_upgrade/server.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@ start_postmaster(ClusterInfo *cluster)
165165
(cluster->controldata.cat_ver >=
166166
BINARY_UPGRADE_SERVER_FLAG_CAT_VER) ? "-b" :
167167
"-c autovacuum=off -c autovacuum_freeze_max_age=2000000000",
168-
cluster->pgopts ? cluster->pgopts : "", SERVER_LOG_FILE2);
168+
cluster->pgopts ? cluster->pgopts : "", SERVER_START_LOG_FILE);
169169

170170
/*
171171
* Don't throw an error right away, let connecting throw the error because
172172
* it might supply a reason for the failure.
173173
*/
174174
pg_ctl_return = exec_prog(false, true,
175175
/* pass both file names if the differ */
176-
(strcmp(SERVER_LOG_FILE, SERVER_LOG_FILE2) == 0) ?
176+
(strcmp(SERVER_LOG_FILE, SERVER_START_LOG_FILE) == 0) ?
177177
SERVER_LOG_FILE :
178-
SERVER_LOG_FILE " or " SERVER_LOG_FILE2,
178+
SERVER_LOG_FILE " or " SERVER_START_LOG_FILE,
179179
"%s", cmd);
180180

181181
/* Check to see if we can connect to the server; if not, report it. */
@@ -214,13 +214,13 @@ stop_postmaster(bool fast)
214214
return; /* no cluster running */
215215

216216
snprintf(cmd, sizeof(cmd),
217-
SYSTEMQUOTE "\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" -o \"%s\" "
217+
SYSTEMQUOTE "\"%s/pg_ctl\" -w -D \"%s\" -o \"%s\" "
218218
"%s stop >> \"%s\" 2>&1" SYSTEMQUOTE,
219-
cluster->bindir, SERVER_LOG_FILE2, cluster->pgconfig,
219+
cluster->bindir, cluster->pgconfig,
220220
cluster->pgopts ? cluster->pgopts : "",
221-
fast ? "-m fast" : "", SERVER_LOG_FILE2);
221+
fast ? "-m fast" : "", SERVER_STOP_LOG_FILE);
222222

223-
exec_prog(fast ? false : true, true, SERVER_LOG_FILE2, "%s", cmd);
223+
exec_prog(fast ? false : true, true, SERVER_STOP_LOG_FILE, "%s", cmd);
224224

225225
os_info.running_cluster = NULL;
226226
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy