{"record":{"id":"80126bde4b238272","repo":"apache/hadoop","slug":"same-delegation-token-being-added-twice-formatto","errorCode":null,"errorMessage":"Same delegation token being added twice: {formatTokenId(identifier)}","messagePattern":"Same delegation token being added twice: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java","lineNumber":483,"sourceCode":"      DelegationKey dKey = allKeys.get(keyId);\n      byte[] password = null;\n      if (dKey == null) {\n        LOG.warn(\"No KEY found for persisted identifier, expiring stored token \" + formatTokenId(\n            identifier));\n        // make sure the token is expired\n        renewDate = 0L;\n      } else {\n        password = createPassword(identifier.getBytes(), dKey.getKey());\n      }\n      if (identifier.getSequenceNumber() > getDelegationTokenSeqNum()) {\n        setDelegationTokenSeqNum(identifier.getSequenceNumber());\n      }\n      if (getTokenInfo(identifier) == null) {\n        currentTokens.put(identifier, new DelegationTokenInformation(renewDate, password,\n            getTrackingIdIfEnabled(identifier)));\n        addTokenForOwnerStats(identifier);\n      } else {\n        throw new IOException(\"Same delegation token being added twice: \" +\n            formatTokenId(identifier));\n      }\n    } finally {\n      this.apiLock.writeLock().unlock();\n    }\n  }\n\n  /** \n   * Update the current master key \n   * This is called once by startThreads before tokenRemoverThread is created, \n   * and only by tokenRemoverThread afterwards.\n   */\n  private void updateCurrentKey() throws IOException {\n    LOG.info(\"Updating the current master key for generating delegation tokens\");\n    /* Create a new currentKey with an estimated expiry date. */\n    int newCurrentId;\n    newCurrentId = incrementCurrentKeyId();\n    DelegationKey newKey = new DelegationKey(newCurrentId, System","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java#L465-L501","documentation":"Error \"Same delegation token being added twice: {formatTokenId(identifier)}\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java:483 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The same delegation token ({formatTokenId(identifier)}) is being added twice, which indicates duplicate recovery/replay from the store. Check the secret manager store for duplicates and clear stale entries, or deduplicate before adding."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}