{"record":{"id":"135a7d490c879efb","repo":"jenkinsci/jenkins","slug":"0-is-currently-being-deleted","errorCode":null,"errorMessage":"{0} is currently being deleted","messagePattern":"(.+?) is currently being deleted","errorType":"exception","errorClass":"Failure","httpStatus":null,"severity":"warning","filePath":"core/src/main/java/hudson/model/AbstractItem.java","lineNumber":791,"sourceCode":"    }\n\n    /**\n     * Deletes this item.\n     *\n     * <p>\n     * Any exception indicates the deletion has failed, but {@link AbortException} would prevent the caller\n     * from showing the stack trace.\n     * @see ItemDeletion\n     */\n    @Override\n    public void delete() throws IOException, InterruptedException {\n        checkPermission(DELETE);\n        ItemListener.checkBeforeDelete(this);\n        boolean responsibleForAbortingBuilds = !ItemDeletion.contains(this);\n        boolean ownsRegistration = ItemDeletion.register(this);\n        if (!ownsRegistration && ItemDeletion.isRegistered(this)) {\n            // we are not the owning thread and somebody else is concurrently deleting this exact item\n            throw new Failure(Messages.AbstractItem_BeingDeleted(getPronoun()));\n        }\n        try {\n            // if a build is in progress. Cancel it.\n            if (responsibleForAbortingBuilds || ownsRegistration) {\n                ItemDeletion.cancelBuildsInProgress(this);\n            }\n            if (this instanceof ItemGroup) {\n                // delete individual items first\n                // (disregard whether they would be deletable in isolation)\n                // JENKINS-34939: do not hold the monitor on this folder while deleting them\n                // (thus we cannot do this inside performDelete)\n                try (ACLContext oldContext = ACL.as2(ACL.SYSTEM2)) {\n                    for (Item i : ((ItemGroup<?>) this).getItems(TopLevelItem.class::isInstance)) {\n                        try {\n                            i.delete();\n                        } catch (AbortException e) {\n                            throw (AbortException) new AbortException(\n                                    \"Failed to delete \" + i.getFullDisplayName() + \" : \" + e.getMessage()).initCause(e);","sourceCodeStart":773,"sourceCodeEnd":809,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/model/AbstractItem.java#L773-L809","documentation":"Thrown by AbstractItem.delete() when the current thread does not own the deletion registration AND the item is already registered as being deleted by another thread. ItemDeletion.register(this) returns false (not owner) and ItemDeletion.isRegistered(this) returns true, indicating a concurrent delete is in progress. The Failure (Stapler) prevents the second caller from proceeding and shows the localized 'BeingDeleted' message with the item's pronoun.","triggerScenarios":"Two concurrent requests/threads call delete() on the same item; the first thread registers as owner, the second thread hits the 'not owner but registered' branch and throws Failure.","commonSituations":"User clicks delete twice rapidly; a REST/CLI delete coincides with a UI delete; an automation script and a manual action race on the same job; a folder deletion iterating children while a child is concurrently deleted.","solutions":["Avoid issuing concurrent delete requests for the same item; serialize deletions"],"exampleFix":"// before: concurrent deletes race\ntry { item.delete(); } catch (Failure f) { /* ignored */ }\n// after: check deletion status first\nif (ItemDeletion.isRegistered(item)) {\n    throw new Failure(item.getFullDisplayName() + \" is already being deleted\");\n}\nitem.delete();","handlingStrategy":"validation","validationCode":"if (ItemDeletion.isRegistered(item)) {\n    throw new IllegalStateException(item.getFullDisplayName() + \" is already being deleted\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    item.delete();\n} catch (Failure f) {\n    if (f.getMessage().contains(\"currently being deleted\")) {\n        // concurrent delete in progress; inform user or retry after a short delay\n    }\n    throw f;\n}","preventionTips":["Do not issue concurrent delete requests for the same item","Check ItemDeletion.isRegistered before calling delete in automation","Guard UI delete buttons against double-submission"],"tags":["item","delete","concurrency","stapler","failure"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}