@@ -803,10 +803,13 @@ delete_walfiles(XLogRecPtr oldest_lsn, TimeLineID oldest_tli,
803
803
int
804
804
do_delete_instance (void )
805
805
{
806
- parray * backup_list ;
807
- int i ;
806
+ parray * backup_list ;
807
+ parray * xlog_files_list ;
808
+ int i ;
809
+ int rc ;
808
810
char instance_config_path [MAXPGPATH ];
809
811
812
+
810
813
/* Delete all backups. */
811
814
backup_list = catalog_get_backup_list (INVALID_BACKUP_ID );
812
815
@@ -823,23 +826,40 @@ do_delete_instance(void)
823
826
parray_free (backup_list );
824
827
825
828
/* Delete all wal files. */
826
- delete_walfiles (InvalidXLogRecPtr , 0 , instance_config .xlog_seg_size );
829
+ xlog_files_list = parray_new ();
830
+ dir_list_file (xlog_files_list , arclog_path , false, false, false, 0 , FIO_BACKUP_HOST );
831
+
832
+ for (i = 0 ; i < parray_num (xlog_files_list ); i ++ )
833
+ {
834
+ pgFile * wal_file = (pgFile * ) parray_get (xlog_files_list , i );
835
+ if (S_ISREG (wal_file -> mode ))
836
+ {
837
+ rc = unlink (wal_file -> path );
838
+ if (rc != 0 )
839
+ elog (WARNING , "Failed to remove file \"%s\": %s" ,
840
+ wal_file -> path , strerror (errno ));
841
+ }
842
+ }
843
+
844
+ /* Cleanup */
845
+ parray_walk (xlog_files_list , pgFileFree );
846
+ parray_free (xlog_files_list );
827
847
828
848
/* Delete backup instance config file */
829
849
join_path_components (instance_config_path , backup_instance_path , BACKUP_CATALOG_CONF_FILE );
830
850
if (remove (instance_config_path ))
831
851
{
832
- elog (ERROR , "can 't remove \"%s\": %s" , instance_config_path ,
852
+ elog (ERROR , "Can 't remove \"%s\": %s" , instance_config_path ,
833
853
strerror (errno ));
834
854
}
835
855
836
856
/* Delete instance root directories */
837
857
if (rmdir (backup_instance_path ) != 0 )
838
- elog (ERROR , "can 't remove \"%s\": %s" , backup_instance_path ,
858
+ elog (ERROR , "Can 't remove \"%s\": %s" , backup_instance_path ,
839
859
strerror (errno ));
840
860
841
861
if (rmdir (arclog_path ) != 0 )
842
- elog (ERROR , "can 't remove \"%s\": %s" , arclog_path ,
862
+ elog (ERROR , "Can 't remove \"%s\": %s" , arclog_path ,
843
863
strerror (errno ));
844
864
845
865
elog (INFO , "Instance '%s' successfully deleted" , instance_name );
0 commit comments