{"record":{"id":"6f4ee659b88e2b15","repo":"apache/hadoop","slug":"can-t-add-delegation-key-to-a-running-secretmanage","errorCode":null,"errorMessage":"Can't add delegation key to a running SecretManager.","messagePattern":"Can't add delegation key to a running SecretManager\\.","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":226,"sourceCode":"\n  /**\n   * Interval for tokens to be renewed.\n   * @return Renew interval in milliseconds.\n   */\n  protected long getTokenRenewInterval() {\n    return this.tokenRenewInterval;\n  }\n\n  /** \n   * Add a previously used master key to cache (when NN restarts), \n   * should be called before activate().\n   *\n   * @param key delegation key.\n   * @throws IOException raised on errors performing I/O.\n   */\n  public void addKey(DelegationKey key) throws IOException {\n    if (running) // a safety check\n      throw new IOException(\"Can't add delegation key to a running SecretManager.\");\n    this.apiLock.writeLock().lock();\n    try {\n      if (key.getKeyId() > getCurrentKeyId()) {\n        setCurrentKeyId(key.getKeyId());\n      }\n      allKeys.put(key.getKeyId(), key);\n    } finally {\n      this.apiLock.writeLock().unlock();\n    }\n  }\n\n  public DelegationKey[] getAllKeys() {\n    this.apiLock.readLock().lock();\n    try {\n      return allKeys.values().toArray(new DelegationKey[0]);\n    } finally {\n      this.apiLock.readLock().unlock();\n    }","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java#L208-L244","documentation":"Error \"Can't add delegation key to a running SecretManager.\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java:226 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Load all persisted delegation keys before calling startThreads()/starting the SecretManager. Keys cannot be added once the manager is running; restart the service to load new keys at startup."],"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"}