@@ -363,22 +363,35 @@ create_new_objects(void)
363363}
364364
365365/*
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
368367 */
369368static void
370- copy_subdir_files (char * subdir )
369+ remove_new_subdir (char * subdir , bool rmtopdir )
371370{
372- char old_path [MAXPGPATH ];
373371 char new_path [MAXPGPATH ];
374372
375373 prep_status ("Deleting files from new %s" , subdir );
376374
377- snprintf (old_path , sizeof (old_path ), "%s/%s" , old_cluster .pgdata , subdir );
378375 snprintf (new_path , sizeof (new_path ), "%s/%s" , new_cluster .pgdata , subdir );
379- if (!rmtree (new_path , true ))
376+ if (!rmtree (new_path , rmtopdir ))
380377 pg_fatal ("could not delete directory \"%s\"\n" , new_path );
378+
381379 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 );
382395
383396 prep_status ("Copying old %s to new server" , subdir );
384397
@@ -419,6 +432,7 @@ copy_clog_xlog_xid(void)
419432 {
420433 copy_subdir_files ("pg_multixact/offsets" );
421434 copy_subdir_files ("pg_multixact/members" );
435+
422436 prep_status ("Setting next multixact ID and offset for new cluster" );
423437
424438 /*
@@ -436,6 +450,13 @@ copy_clog_xlog_xid(void)
436450 }
437451 else if (new_cluster .controldata .cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER )
438452 {
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+
439460 prep_status ("Setting oldest multixact ID on new cluster" );
440461
441462 /*
0 commit comments