{"record":{"id":"053900b7e3931bca","repo":"apache/hadoop","slug":"the-creation-time-for-the-record-cannot-be-negativ","errorCode":null,"errorMessage":"The creation time for the record cannot be negative.","messagePattern":"The creation 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":260,"sourceCode":"   */\n  public boolean shouldBeDeleted(long currentTime) {\n    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":242,"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#L242-L270","documentation":"BaseRecord.validate() runs when a record is created, populated from the state store, and before committing to it. It requires dateCreated > 0; a missing or zero creation timestamp throws IllegalArgumentException(ERROR_MSG_CREATION_TIME_NEGATIVE). Records normally get their timestamps defaulted when persisted, so this fires on records whose creation date was never set — typically deserialized legacy data or programmatically built records that skipped initialization.","triggerScenarios":"Reading state store rows written by an older Hadoop version that did not populate dateCreated; manually inserted or migrated records lacking the column value; custom BaseRecord subclasses constructed via newInstance and put into the store without setting timestamps before validate().","commonSituations":"RBF upgrade with old persisted membership/mount records; hand-edited or migrated state store; a new custom record implementation forgetting timestamp initialization; test fixtures building records directly.","solutions":["Identify the failing record class from the logs and rebuild that state store data — membership and mounts regenerate from heartbeats/config after the stale entries are removed.","If you maintain a custom record type, default the timestamps: set dateCreated/dateModified to Time.now() in the constructor or before put().","For upgrades, clear (or migrate with timestamps filled) the dev/test state store rather than reusing old rows.","If writing records programmatically, always go through the builder/newInstance path that stamps dates on commit."],"exampleFix":"// before: record validated/committed without a creation date\nMembershipState m = MembershipState.newInstance();\nm.setNameserviceId(\"ns1\");\nstore.put(m); // validate() -> IllegalArgumentException\n\n// after: stamp both timestamps before committing\nm.setDateCreated(Time.now());\nm.setDateModified(Time.now());\nstore.put(m);","handlingStrategy":"validation","validationCode":"// Stamp timestamps before validate/put\nlong now = Time.now();\nrecord.setDateCreated(now);\nrecord.setDateModified(now);\n// or use the builder/newInstance path that defaults dates on commit","typeGuard":null,"tryCatchPattern":"try {\n  record.validate();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"creation time\")) {\n    record.setDateCreated(Time.now()); // repair in dev tooling; investigate source in prod\n    record.validate();\n  } else { throw e; }\n}","preventionTips":["Never hand-construct BaseRecord subclasses for the store without setting both timestamps.","Discard or migrate pre-upgrade state store data rather than reading rows lacking date columns.","In custom record types, default dates in the constructor so validate() can never see zero."],"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"}