Repository navigation
Description
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 forType.DATETIME;
DATETIME_SECOND,DATETIME_MICROSandDATETIME_NANOSfall through tojavaDefaultTypeand 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.dateTimeTHROWS for
Date/CalendaratMICROSorNANOS.
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 bytesOutput:
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/Calendarare not meant to be usable with a sub-millisecond column, refuse it at DDL time -
CREATE PROPERTY T.dtm DATETIME_MICROSon a database configured that way should fail with the message
DateUtils.dateTimealready has, instead of deferring it to every read forever after; or - materialise a sub-millisecond column as
LocalDateTimeregardless of the setting (i.e. have the read side apply
the setting toTYPE_DATETIME/TYPE_DATETIME_SECONDonly, matching whatgetJavaImplementationalready 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
Merge pull request #8226 from ArcadeData/fix/issue-8187-8170-8158-815…
lvca commentedon Sep 23, 2026
Fixed in #8226, will be released in 26.10.1.
java.util.Dateandjava.util.Calendarcan't hold sub-millisecond precision. With either of them configured inarcadedb.dateTimeImplementation,DATETIME_MICROSandDATETIME_NANOSvalues are now returned asjava.time.LocalDateTimeinstead ofnull. Nothing was ever lost on disk: existing data reads back correctly after the upgrade.DATETIMEandDATETIME_SECONDkeep 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.
fix(ArcadeData#8187,ArcadeData#8170,ArcadeData#8158,ArcadeData#8153,A…
Merge origin/main into fix/main-red-ci, address review