{"record":{"id":"557498c7215c2671","repo":"elastic/elasticsearch","slug":"interrupted-while-deleting","errorCode":null,"errorMessage":"Interrupted while deleting.","messagePattern":"Interrupted while deleting\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"warning","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java","lineNumber":1236,"sourceCode":"            LOGGER.info(\"[{}] Timed out waiting for process to exit\", name, e);\n        }\n    }\n\n    private static final int RETRY_DELETE_MILLIS = OS.current() == OS.WINDOWS ? 500 : 0;\n    private static final int MAX_RETRY_DELETE_TIMES = OS.current() == OS.WINDOWS ? 15 : 0;\n\n    /**\n     * Deletes a path, retrying if necessary.\n     *\n     * @param path  the path to delete\n     * @throws IOException\n     *         if an I/O error occurs\n     */\n    void deleteWithRetry(Path path) throws IOException {\n        try {\n            deleteWithRetry0(path);\n        } catch (InterruptedException x) {\n            throw new IOException(\"Interrupted while deleting.\", x);\n        }\n    }\n\n    /** Unchecked variant of deleteWithRetry. */\n    void uncheckedDeleteWithRetry(Path path) {\n        try {\n            deleteWithRetry0(path);\n        } catch (IOException e) {\n            throw new UncheckedIOException(e);\n        } catch (InterruptedException x) {\n            throw new UncheckedIOException(\"Interrupted while deleting.\", new IOException());\n        }\n    }\n\n    // The exception handling here is loathsome, but necessary!\n    private void deleteWithRetry0(Path path) throws IOException, InterruptedException {\n        int times = 0;\n        IOException ioe = null;","sourceCodeStart":1218,"sourceCodeEnd":1254,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java#L1218-L1254","documentation":"Thrown by deleteWithRetry(Path) when its inner deleteWithRetry0 is interrupted (InterruptedException caught). It is the checked variant — the method declares throws IOException. The thread's interrupt status is NOT re-set here (note: only the wrapper at line 1247 restores it via the caller pattern in some paths). Retries are Windows-only (MAX_RETRY_DELETE_TIMES=15, RETRY_DELETE_MILLIS=500ms).","triggerScenarios":"A gradle task or test framework interrupts the thread while deleteWithRetry0 is in Thread.sleep(RETRY_DELETE_MILLIS) between delete attempts. The sleep is only entered on Windows when Files.notExists(path) is still false after a delete.","commonSituations":"Gradle cancels the build (Ctrl-C, task timeout, daemon eviction) during cluster teardown on Windows; a watchdog interrupts the cleanup thread.","solutions":["If this was a user-initiated cancellation, ignore it — the interrupt is expected.","If unexpected, check the gradle daemon logs for why the thread was interrupted (daemon memory pressure, timeout).","On Windows, ensure no other process (antivirus, file explorer) holds the file so the delete succeeds on the first attempt without entering the retry/sleep loop."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    deleteWithRetry0(path);\n} catch (InterruptedException x) {\n    throw new IOException(\"Interrupted while deleting.\", x);\n}","preventionTips":["On Windows, close all handles on the path before teardown to avoid the retry/sleep loop.","Avoid cancelling the build during cluster teardown."],"tags":["testclusters","delete","interruption","windows"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}