Github user adeneche commented on a diff in the pull request: https://github.com/apache/drill/pull/454#discussion_r60447085 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatch.java --- @@ -550,7 +565,15 @@ public BatchGroup mergeAndSpill(LinkedList<BatchGroup> batchGroups) throws Schem c1.buildSchema(BatchSchema.SelectionVectorMode.NONE); c1.setRecordCount(count); - String outputFile = Joiner.on("/").join(dirs.next(), fileName, spillCount++); + String spillDir = dirs.next(); + Path currSpillPath = new Path(Joiner.on("/").join(spillDir, fileName)); + currSpillDirs.add(currSpillPath); + String outputFile = Joiner.on("/").join(currSpillPath, spillCount++); + try { + fs.deleteOnExit(currSpillPath); + } catch (IOException e) { + throw new RuntimeException(e); --- End diff -- I have some concerns about throwing an exception here: First, does it make sense to fail the query when `deleteOnExit()` fails ? shouldn't we just log a warning. After all, if all goes well, this folder will get deleted in the close method. Second, if this exception throws we'll be leaking memory because we'll skip clearing batchGroupList and hyperBatch
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---