@@ -363,22 +363,35 @@ create_new_objects(void)
363
363
}
364
364
365
365
/*
366
- * Delete the given subdirectory contents from the new cluster, and copy the
367
- * files from the old cluster into it.
366
+ * Delete the given subdirectory contents from the new cluster
368
367
*/
369
368
static void
370
- copy_subdir_files (char * subdir )
369
+ remove_new_subdir (char * subdir , bool rmtopdir )
371
370
{
372
- char old_path [MAXPGPATH ];
373
371
char new_path [MAXPGPATH ];
374
372
375
373
prep_status ("Deleting files from new %s" , subdir );
376
374
377
- snprintf (old_path , sizeof (old_path ), "%s/%s" , old_cluster .pgdata , subdir );
378
375
snprintf (new_path , sizeof (new_path ), "%s/%s" , new_cluster .pgdata , subdir );
379
- if (!rmtree (new_path , true ))
376
+ if (!rmtree (new_path , rmtopdir ))
380
377
pg_fatal ("could not delete directory \"%s\"\n" , new_path );
378
+
381
379
check_ok ();
380
+ }
381
+
382
+ /*
383
+ * Copy the files from the old cluster into it
384
+ */
385
+ static void
386
+ copy_subdir_files (char * subdir )
387
+ {
388
+ char old_path [MAXPGPATH ];
389
+ char new_path [MAXPGPATH ];
390
+
391
+ remove_new_subdir (subdir , true);
392
+
393
+ snprintf (old_path , sizeof (old_path ), "%s/%s" , old_cluster .pgdata , subdir );
394
+ snprintf (new_path , sizeof (new_path ), "%s/%s" , new_cluster .pgdata , subdir );
382
395
383
396
prep_status ("Copying old %s to new server" , subdir );
384
397
@@ -419,6 +432,7 @@ copy_clog_xlog_xid(void)
419
432
{
420
433
copy_subdir_files ("pg_multixact/offsets" );
421
434
copy_subdir_files ("pg_multixact/members" );
435
+
422
436
prep_status ("Setting next multixact ID and offset for new cluster" );
423
437
424
438
/*
@@ -436,6 +450,13 @@ copy_clog_xlog_xid(void)
436
450
}
437
451
else if (new_cluster .controldata .cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER )
438
452
{
453
+ /*
454
+ * Remove files created by initdb that no longer match the
455
+ * new multi-xid value.
456
+ */
457
+ remove_new_subdir ("pg_multixact/offsets" , false);
458
+ remove_new_subdir ("pg_multixact/members" , false);
459
+
439
460
prep_status ("Setting oldest multixact ID on new cluster" );
440
461
441
462
/*
0 commit comments