{"record":{"id":"208e5f15b6997cb2","repo":"apache/hadoop","slug":"failed-to-increment-token-sequence-number-in-sql-s","errorCode":null,"errorMessage":"Failed to increment token sequence number in SQL secret manager","messagePattern":"Failed to increment token sequence number in SQL secret manager","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/SQLDelegationTokenSecretManager.java","lineNumber":319,"sourceCode":"  /**\n   * Obtains the next available sequence number that can be allocated to a Token.\n   * Sequence numbers need to be reserved using the shared sequenceNumberCounter once\n   * the local batch has been exhausted, which handles sequenceNumber allocation\n   * concurrently with other secret managers.\n   * This method ensures that sequence numbers are incremental in a single secret manager,\n   * but not across secret managers.\n   * @return Next available sequence number.\n   */\n  @Override\n  public synchronized int incrementDelegationTokenSeqNum() {\n    if (currentSeqNum >= currentMaxSeqNum) {\n      try {\n        // Request a new batch of sequence numbers and use the\n        // lowest one available.\n        currentSeqNum = incrementSequenceNum(seqNumBatchSize);\n        currentMaxSeqNum = currentSeqNum + seqNumBatchSize;\n      } catch (SQLException e) {\n        throw new RuntimeException(\n            \"Failed to increment token sequence number in SQL secret manager\", e);\n      }\n    }\n\n    return ++currentSeqNum;\n  }\n\n  /**\n   * Persists a DelegationKey into the SQL database. The delegation keyId\n   * is expected to be unique and any duplicate key attempts will result\n   * in an IOException.\n   * @param key DelegationKey to persist into the SQL database.\n   */\n  @Override\n  protected void storeDelegationKey(DelegationKey key) throws IOException {\n    try (ByteArrayOutputStream bos = new ByteArrayOutputStream();\n        DataOutputStream dos = new DataOutputStream(bos)) {\n      key.write(dos);","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/SQLDelegationTokenSecretManager.java#L301-L337","documentation":"Error \"Failed to increment token sequence number in SQL secret manager\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/SQLDelegationTokenSecretManager.java:319 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Incrementing the token sequence number in the SQL store failed. Check for concurrent writers, deadlocks, or connection loss; see the chained SQLException."],"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-23T01:17:44.959Z"}