diff --git a/indexing-hadoop/src/main/java/io/druid/indexer/JobHelper.java b/indexing-hadoop/src/main/java/io/druid/indexer/JobHelper.java index 0148cad7582..d4eda3aeaed 100644 --- a/indexing-hadoop/src/main/java/io/druid/indexer/JobHelper.java +++ b/indexing-hadoop/src/main/java/io/druid/indexer/JobHelper.java @@ -774,4 +774,26 @@ public class JobHelper } }; } + + public static boolean deleteWithRetry(final FileSystem fs, final Path path, final boolean recursive) + { + try { + return RetryUtils.retry( + new Callable() + { + @Override + public Boolean call() throws Exception + { + return fs.delete(path, recursive); + } + }, + shouldRetryPredicate(), + NUM_RETRIES + ); + } + catch (Exception e) { + log.error(e, "Failed to cleanup path[%s]", path); + throw Throwables.propagate(e); + } + } } diff --git a/indexing-hadoop/src/main/java/io/druid/indexer/updater/HadoopConverterJob.java b/indexing-hadoop/src/main/java/io/druid/indexer/updater/HadoopConverterJob.java index 451b1fa9561..db8d9ff6c72 100644 --- a/indexing-hadoop/src/main/java/io/druid/indexer/updater/HadoopConverterJob.java +++ b/indexing-hadoop/src/main/java/io/druid/indexer/updater/HadoopConverterJob.java @@ -147,8 +147,26 @@ public class HadoopConverterJob { final Path jobDir = getJobPath(job.getJobID(), job.getWorkingDirectory()); final FileSystem fs = jobDir.getFileSystem(job.getConfiguration()); - fs.delete(jobDir, true); - fs.delete(getJobClassPathDir(job.getJobName(), job.getWorkingDirectory()), true); + RuntimeException e = null; + try { + JobHelper.deleteWithRetry(fs, jobDir, true); + } + catch (RuntimeException ex) { + e = ex; + } + try { + JobHelper.deleteWithRetry(fs, getJobClassPathDir(job.getJobName(), job.getWorkingDirectory()), true); + } + catch (RuntimeException ex) { + if (e == null) { + e = ex; + } else { + e.addSuppressed(ex); + } + } + if (e != null) { + throw e; + } }