Skip to content

arcadedb.dateTimeImplementation set to java.util.Date or java.util.Calendar makes every DATETIME_MICROS and DATETIME_NANOS column write successfully and read back as null #8158

Closed

Description

@ruispereira

Summary

Which Java class a datetime column is materialised into is arcadedb.dateTimeImplementation, and the setting's own
description lists java.util.Date and java.util.Calendar among the supported values. The two sides of the record
path disagree about who that setting applies to:

  • the WRITE side asks Type.getJavaImplementation(database), which consults the setting only for Type.DATETIME;
    DATETIME_SECOND, DATETIME_MICROS and DATETIME_NANOS fall through to javaDefaultType and are stored as
    LocalDateTime, so the write succeeds and the value lands on disk at full precision;
  • the READ side applies the setting to ALL FOUR binary datetime types, and DateUtils.dateTime THROWS for
    Date/Calendar at MICROS or NANOS.

BinarySerializer.deserializeProperties has a per-property recovery arm whose purpose is to survive a corrupt
value, and it catches this IllegalArgumentException, logs Skipping corrupted property ... at WARNING and leaves
the property out of the map. The caller sees null. Nothing is corrupt: the same bytes read back perfectly the
moment the setting is changed. So a database configured this way accepts writes to those columns for as long as you
like and answers every read with null, while its log accuses the records of being damaged.

DATETIME (millis) is unaffected in both directions, which is why the misconfiguration is easy to miss: the
commonest column type works.

Where (HEAD 9a88be7)

engine/src/main/java/com/arcadedb/schema/Type.java:1945 - only two of the five datetime types consult the setting:

  public Class<?> getJavaImplementation(final Database database) {
    if (database instanceof DatabaseInternal internal) {
      if (this == DATE)
        return internal.getSerializer().getDateImplementation();
      if (this == DATETIME)
        return internal.getSerializer().getDateTimeImplementation();
    }
    return javaDefaultType;
  }

engine/src/main/java/com/arcadedb/serializer/BinarySerializer.java:851 - the read side applies it to all of them:

    case BinaryTypes.TYPE_DATETIME_MICROS:
      value = DateUtils.dateTime(database, content.getUnsignedNumber(), ChronoUnit.MICROS, dateTimeImplementation,
          ChronoUnit.MICROS);

engine/src/main/java/com/arcadedb/utility/DateUtils.java:110 - where it gives up:

    if (dateTimeImplementation.equals(Date.class)) {
      if (destinationPrecision == ChronoUnit.MICROS || destinationPrecision == ChronoUnit.NANOS)
        throw new IllegalArgumentException(
            "java.util.Date implementation cannot handle datetime with precision " + destinationPrecision);

(and the identical arm for Calendar on the next branch)

engine/src/main/java/com/arcadedb/serializer/BinarySerializer.java:357 - where it turns into a null:

        } catch (Exception e) {
          LogManager.instance().log(this, Level.WARNING,
              "Skipping corrupted property '%s' in record %s: %s", propertyName, rid, e.getMessage());
        }

engine/src/main/java/com/arcadedb/GlobalConfiguration.java:199 - the setting that says both classes are supported.

Repro

db.command("sql", "ALTER DATABASE `arcadedb.dateTimeImplementation` 'java.time.LocalDateTime'");
db.command("sql", "CREATE DOCUMENT TYPE T");
db.command("sql", "CREATE PROPERTY T.dtm DATETIME_MICROS");
db.command("sql", "CREATE PROPERTY T.dtn DATETIME_NANOS");
db.transaction(() -> db.command("sql",
    "INSERT INTO T SET dtm = '2024-02-29 13:45:10.123456', dtn = '2024-02-29 13:45:10.123456789'"));
// reads fine
db.command("sql", "ALTER DATABASE `arcadedb.dateTimeImplementation` 'java.util.Date'");
// same records, same bytes

Output:

LocalDateTime impl: dtm=2024-02-29T13:45:10.123456 dtn=2024-02-29T13:45:10.123456789
java.lang.IllegalArgumentException: java.util.Date implementation cannot handle datetime with precision Micros
java.lang.IllegalArgumentException: java.util.Date implementation cannot handle datetime with precision Nanos
Date impl SQL:      dtm=null dtn=null
java.lang.IllegalArgumentException: java.util.Date implementation cannot handle datetime with precision Micros
java.lang.IllegalArgumentException: java.util.Date implementation cannot handle datetime with precision Nanos
Date impl Java API: dtm=null dtn=null props=[dtm, dtn]

And starting from a fresh database created with the setting already on java.util.Date (or java.util.Calendar),
every INSERT INTO T SET dtm = '...' reports success and every SELECT dtm answers null, for all four literal
spellings tried (2024-02-29 13:45:10, ...10.123456, 2024-02-29T13:45:10, 2024-02-29).

Suggested fix

Make the two sides agree, in whichever direction is intended:

  • if Date/Calendar are not meant to be usable with a sub-millisecond column, refuse it at DDL time -
    CREATE PROPERTY T.dtm DATETIME_MICROS on a database configured that way should fail with the message
    DateUtils.dateTime already has, instead of deferring it to every read forever after; or
  • materialise a sub-millisecond column as LocalDateTime regardless of the setting (i.e. have the read side apply
    the setting to TYPE_DATETIME/TYPE_DATETIME_SECOND only, matching what getJavaImplementation already does on
    the write side), and say so in the setting's description.

Independently: a deserialisation failure that is a CONFIGURATION mismatch should not be reported through the
corrupt-property recovery arm. That arm exists to keep the rest of a damaged record readable, and using it here
tells an operator their data is damaged when it is intact.

Scope / confidence

Reproduced end to end, both from a database whose setting was changed after the write and from one created with the
setting in place. Old code rather than churn: neither BinarySerializer nor DateUtils.dateTime's implementation
switch was touched in this batch. It is in the middle of the ground #8090 has just been working over - the
precision-bearing datetime types, which DocumentValidator only started handling at all in this batch - which is
why it is worth filing now. Does not affect the default configuration (java.time.LocalDateTime), nor DATETIME,
nor DATETIME_SECOND.

Activity

  1. added
    engine
    severity:major
    on Sep 22, 2026
  2. added this to the 26.10.1 milestone on Sep 22, 2026
  3. added
    in progress
    on Sep 22, 2026
  4. self-assigned this
    on Sep 22, 2026
  5. added a commit that references this issue on Sep 23, 2026
  6. lvca commented on Sep 23, 2026

    @lvca
    Member

    Fixed in #8226, will be released in 26.10.1.

    java.util.Date and java.util.Calendar can't hold sub-millisecond precision. With either of them configured in arcadedb.dateTimeImplementation, DATETIME_MICROS and DATETIME_NANOS values are now returned as java.time.LocalDateTime instead of null. Nothing was ever lost on disk: existing data reads back correctly after the upgrade. DATETIME and DATETIME_SECOND keep using the configured class. The setting's description now says this.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  7. removed
    in progress
    on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugengineseverity:major

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions