Skip to content

Commit 6837632

Browse files
committed
Fix issues in pg_rewind with --no-ensure-shutdown/--write-recovery-conf
This fixes two issues with recent features added in pg_rewind: - --dry-run should do nothing on the target directory, but 927474c forgot to consider that for --write-recovery-conf. - --no-ensure-shutdown was not actually working. There is no test coverage for this option yet, but a subsequent patch will add that. Author: Alexey Kondratov Discussion: https://postgr.es/m/7ca88204-3e0b-2f4c-c8af-acadc4b266e5@postgrespro.ru
1 parent 6f3823b commit 6837632

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/bin/pg_rewind/pg_rewind.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ main(int argc, char **argv)
101101
{"write-recovery-conf", no_argument, NULL, 'R'},
102102
{"source-pgdata", required_argument, NULL, 1},
103103
{"source-server", required_argument, NULL, 2},
104-
{"no-ensure-shutdown", no_argument, NULL, 44},
104+
{"no-ensure-shutdown", no_argument, NULL, 4},
105105
{"version", no_argument, NULL, 'V'},
106106
{"dry-run", no_argument, NULL, 'n'},
107107
{"no-sync", no_argument, NULL, 'N'},
@@ -180,9 +180,11 @@ main(int argc, char **argv)
180180
case 1: /* --source-pgdata */
181181
datadir_source = pg_strdup(optarg);
182182
break;
183+
183184
case 2: /* --source-server */
184185
connstr_source = pg_strdup(optarg);
185186
break;
187+
186188
case 4:
187189
no_ensure_shutdown = true;
188190
break;
@@ -341,7 +343,7 @@ main(int argc, char **argv)
341343
if (!rewind_needed)
342344
{
343345
pg_log_info("no rewind required");
344-
if (writerecoveryconf)
346+
if (writerecoveryconf && !dry_run)
345347
WriteRecoveryConfig(conn, datadir_target,
346348
GenerateRecoveryConfig(conn, NULL));
347349
exit(0);
@@ -442,7 +444,7 @@ main(int argc, char **argv)
442444
pg_log_info("syncing target data directory");
443445
syncTargetDirectory();
444446

445-
if (writerecoveryconf)
447+
if (writerecoveryconf && !dry_run)
446448
WriteRecoveryConfig(conn, datadir_target,
447449
GenerateRecoveryConfig(conn, NULL));
448450

0 commit comments

Comments
 (0)