{"record":{"id":"e825f0aa01812038","repo":"apache/hadoop","slug":"the-modification-time-for-the-record-cannot-be-neg","errorCode":null,"errorMessage":"The modification time for the record cannot be negative.","messagePattern":"The modification time for the record cannot be negative\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/records/BaseRecord.java","lineNumber":262,"sourceCode":"    long deletionTime = getDeletionMs();\n    if (isExpired() && deletionTime > 0) {\n      long elapsedTime = currentTime - (getDateModified() + getExpirationMs());\n      return elapsedTime > deletionTime;\n    } else {\n      return false;\n    }\n  }\n\n  /**\n   * Validates the record. Called when the record is created, populated from the\n   * state store, and before committing to the state store. If validate failed,\n   * there throws an exception.\n   */\n  public void validate() {\n    if (getDateCreated() <= 0) {\n      throw new IllegalArgumentException(ERROR_MSG_CREATION_TIME_NEGATIVE);\n    } else if (getDateModified() <= 0) {\n      throw new IllegalArgumentException(ERROR_MSG_MODIFICATION_TIME_NEGATIVE);\n    }\n  }\n\n  @Override\n  public String toString() {\n    return getPrimaryKey();\n  }\n}","sourceCodeStart":244,"sourceCodeEnd":270,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/records/BaseRecord.java#L244-L270","documentation":"BaseRecord.validate() also requires dateModified > 0 and throws IllegalArgumentException(ERROR_MSG_MODIFICATION_TIME_NEGATIVE) otherwise. dateModified is stamped on every state store update, so a zero/negative value means the record was produced without the normal write path — legacy persisted rows, hand-built records, or a custom record type that never sets modification time.","triggerScenarios":"Deserializing old state store records whose dateModified column is absent/zero; constructing BaseRecord subclasses in code or tests and calling put/validate without setDateModified; migration tooling copying rows without the timestamp columns.","commonSituations":"Version upgrades carrying forward old state store data; manually crafted records in unit tests; custom record implementations missing the timestamp defaulting.","solutions":["Remove or migrate the stale records so they regenerate through the normal write path (heartbeats for membership, config sync for mounts).","In custom record code, default dateModified (and dateCreated) to the current time before validate/put.","After a Hadoop upgrade, reset dev/test state stores instead of reusing pre-upgrade rows.","Audit migration scripts to copy dateCreated/dateModified columns."],"exampleFix":"// before: only creation date set\nrecord.setDateCreated(Time.now());\nstore.put(record); // throws: modification time negative\n\n// after: set both timestamps\nlong now = Time.now();\nrecord.setDateCreated(now);\nrecord.setDateModified(now);\nstore.put(record);","handlingStrategy":"validation","validationCode":"if (record.getDateModified() <= 0) {\n  record.setDateModified(Time.now());\n}\nrecord.validate();","typeGuard":null,"tryCatchPattern":"try {\n  record.validate();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"modification time\")) {\n    record.setDateModified(Time.now()); // dev tooling repair; audit data source in prod\n    record.validate();\n  } else { throw e; }\n}","preventionTips":["Route all record writes through the state store API, which stamps dateModified on update.","Include dateCreated/dateModified columns in any migration/copy of state store rows.","Unit-test custom record builders by calling validate() before put."],"tags":["hdfs","router-based-federation","state-store","record-validation","timestamps"],"backgroundTag":"record-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}