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