Skip to content

Commit 3b97c4f

Browse files
committed
minor bugfix: del-instance was failing due to presense of .history files in archive directory
1 parent 74b25e4 commit 3b97c4f

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/delete.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,13 @@ delete_walfiles(XLogRecPtr oldest_lsn, TimeLineID oldest_tli,
803803
int
804804
do_delete_instance(void)
805805
{
806-
parray *backup_list;
807-
int i;
806+
parray *backup_list;
807+
parray *xlog_files_list;
808+
int i;
809+
int rc;
808810
char instance_config_path[MAXPGPATH];
809811

812+
810813
/* Delete all backups. */
811814
backup_list = catalog_get_backup_list(INVALID_BACKUP_ID);
812815

@@ -823,23 +826,40 @@ do_delete_instance(void)
823826
parray_free(backup_list);
824827

825828
/* 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);
827847

828848
/* Delete backup instance config file */
829849
join_path_components(instance_config_path, backup_instance_path, BACKUP_CATALOG_CONF_FILE);
830850
if (remove(instance_config_path))
831851
{
832-
elog(ERROR, "can't remove \"%s\": %s", instance_config_path,
852+
elog(ERROR, "Can't remove \"%s\": %s", instance_config_path,
833853
strerror(errno));
834854
}
835855

836856
/* Delete instance root directories */
837857
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,
839859
strerror(errno));
840860

841861
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,
843863
strerror(errno));
844864

845865
elog(INFO, "Instance '%s' successfully deleted", instance_name);

0 commit comments

Comments
 (0)