mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
pg_upgrade: more Windows parallel/-j fixes
More fixes to handle Windows thread parameter passing. Backpatch to 9.3 beta. Patch originally from Andrew Dunstan
This commit is contained in:
parent
d7de6a4790
commit
910d3a458c
@ -32,18 +32,18 @@ HANDLE *thread_handles;
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char log_file[MAXPGPATH];
|
char *log_file;
|
||||||
char opt_log_file[MAXPGPATH];
|
char *opt_log_file;
|
||||||
char cmd[MAX_STRING];
|
char *cmd;
|
||||||
} exec_thread_arg;
|
} exec_thread_arg;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
DbInfoArr *old_db_arr;
|
DbInfoArr *old_db_arr;
|
||||||
DbInfoArr *new_db_arr;
|
DbInfoArr *new_db_arr;
|
||||||
char old_pgdata[MAXPGPATH];
|
char *old_pgdata;
|
||||||
char new_pgdata[MAXPGPATH];
|
char *new_pgdata;
|
||||||
char old_tablespace[MAXPGPATH];
|
char *old_tablespace;
|
||||||
} transfer_thread_arg;
|
} transfer_thread_arg;
|
||||||
|
|
||||||
exec_thread_arg **exec_thread_args;
|
exec_thread_arg **exec_thread_args;
|
||||||
@ -113,10 +113,12 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
|
|||||||
pg_log(PG_FATAL, "could not create worker process: %s\n", strerror(errno));
|
pg_log(PG_FATAL, "could not create worker process: %s\n", strerror(errno));
|
||||||
#else
|
#else
|
||||||
if (thread_handles == NULL)
|
if (thread_handles == NULL)
|
||||||
|
thread_handles = pg_malloc(user_opts.jobs * sizeof(HANDLE));
|
||||||
|
|
||||||
|
if (exec_thread_args == NULL)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
thread_handles = pg_malloc(user_opts.jobs * sizeof(HANDLE));
|
|
||||||
exec_thread_args = pg_malloc(user_opts.jobs * sizeof(exec_thread_arg *));
|
exec_thread_args = pg_malloc(user_opts.jobs * sizeof(exec_thread_arg *));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -125,16 +127,22 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
|
|||||||
* thread different from the one that allocated it.
|
* thread different from the one that allocated it.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < user_opts.jobs; i++)
|
for (i = 0; i < user_opts.jobs; i++)
|
||||||
exec_thread_args[i] = pg_malloc(sizeof(exec_thread_arg));
|
exec_thread_args[i] = pg_malloc0(sizeof(exec_thread_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use first empty array element */
|
/* use first empty array element */
|
||||||
new_arg = exec_thread_args[parallel_jobs - 1];
|
new_arg = exec_thread_args[parallel_jobs - 1];
|
||||||
|
|
||||||
/* Can only pass one pointer into the function, so use a struct */
|
/* Can only pass one pointer into the function, so use a struct */
|
||||||
strcpy(new_arg->log_file, log_file);
|
if (new_arg->log_file)
|
||||||
strcpy(new_arg->opt_log_file, opt_log_file);
|
pg_free(new_arg->log_file);
|
||||||
strcpy(new_arg->cmd, cmd);
|
new_arg->log_file = pg_strdup(log_file);
|
||||||
|
if (new_arg->opt_log_file)
|
||||||
|
pg_free(new_arg->opt_log_file);
|
||||||
|
new_arg->opt_log_file = opt_log_file ? pg_strdup(opt_log_file) : NULL;
|
||||||
|
if (new_arg->cmd)
|
||||||
|
pg_free(new_arg->cmd);
|
||||||
|
new_arg->cmd = pg_strdup(cmd);
|
||||||
|
|
||||||
child = (HANDLE) _beginthreadex(NULL, 0, (void *) win32_exec_prog,
|
child = (HANDLE) _beginthreadex(NULL, 0, (void *) win32_exec_prog,
|
||||||
new_arg, 0, NULL);
|
new_arg, 0, NULL);
|
||||||
@ -219,10 +227,12 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
|
|||||||
pg_log(PG_FATAL, "could not create worker process: %s\n", strerror(errno));
|
pg_log(PG_FATAL, "could not create worker process: %s\n", strerror(errno));
|
||||||
#else
|
#else
|
||||||
if (thread_handles == NULL)
|
if (thread_handles == NULL)
|
||||||
|
thread_handles = pg_malloc(user_opts.jobs * sizeof(HANDLE));
|
||||||
|
|
||||||
|
if (transfer_thread_args == NULL)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
thread_handles = pg_malloc(user_opts.jobs * sizeof(HANDLE));
|
|
||||||
transfer_thread_args = pg_malloc(user_opts.jobs * sizeof(transfer_thread_arg *));
|
transfer_thread_args = pg_malloc(user_opts.jobs * sizeof(transfer_thread_arg *));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -231,7 +241,7 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
|
|||||||
* thread different from the one that allocated it.
|
* thread different from the one that allocated it.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < user_opts.jobs; i++)
|
for (i = 0; i < user_opts.jobs; i++)
|
||||||
transfer_thread_args[i] = pg_malloc(sizeof(transfer_thread_arg));
|
transfer_thread_args[i] = pg_malloc0(sizeof(transfer_thread_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use first empty array element */
|
/* use first empty array element */
|
||||||
@ -240,9 +250,15 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
|
|||||||
/* Can only pass one pointer into the function, so use a struct */
|
/* Can only pass one pointer into the function, so use a struct */
|
||||||
new_arg->old_db_arr = old_db_arr;
|
new_arg->old_db_arr = old_db_arr;
|
||||||
new_arg->new_db_arr = new_db_arr;
|
new_arg->new_db_arr = new_db_arr;
|
||||||
strcpy(new_arg->old_pgdata, old_pgdata);
|
if (new_arg->old_pgdata)
|
||||||
strcpy(new_arg->new_pgdata, new_pgdata);
|
pg_free(new_arg->old_pgdata);
|
||||||
strcpy(new_arg->old_tablespace, old_tablespace);
|
new_arg->old_pgdata = pg_strdup(old_pgdata);
|
||||||
|
if (new_arg->new_pgdata)
|
||||||
|
pg_free(new_arg->new_pgdata);
|
||||||
|
new_arg->new_pgdata = pg_strdup(new_pgdata);
|
||||||
|
if (new_arg->old_tablespace)
|
||||||
|
pg_free(new_arg->old_tablespace);
|
||||||
|
new_arg->old_tablespace = old_tablespace ? pg_strdup(old_tablespace) : NULL;
|
||||||
|
|
||||||
child = (HANDLE) _beginthreadex(NULL, 0, (void *) win32_transfer_all_new_dbs,
|
child = (HANDLE) _beginthreadex(NULL, 0, (void *) win32_transfer_all_new_dbs,
|
||||||
new_arg, 0, NULL);
|
new_arg, 0, NULL);
|
||||||
|
@ -152,7 +152,7 @@ PGDATA=$BASE_PGDATA
|
|||||||
|
|
||||||
initdb -N
|
initdb -N
|
||||||
|
|
||||||
pg_upgrade -d "${PGDATA}.old" -D "${PGDATA}" -b "$oldbindir" -B "$bindir" -p "$PGPORT" -P "$PGPORT"
|
pg_upgrade $PG_UPGRADE_OPTS -d "${PGDATA}.old" -D "${PGDATA}" -b "$oldbindir" -B "$bindir" -p "$PGPORT" -P "$PGPORT"
|
||||||
|
|
||||||
pg_ctl start -l "$logdir/postmaster2.log" -o "$POSTMASTER_OPTS" -w
|
pg_ctl start -l "$logdir/postmaster2.log" -o "$POSTMASTER_OPTS" -w
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user