Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ public void store(Item item) {
@Override
public void store(Item item, @Nullable String alias) {
// Timestamp and capture state immediately as rest of the store is asynchronous (state might change in between)
ZonedDateTime time = ZonedDateTime.now();
ZonedDateTime lastStateUpdate = item.getLastStateUpdate();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it guaranteed by the core that this timestamp is updated when persistence is called?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. If it isn't mapdb would have been badly broken for a long time and that would be Bad. It would also be a bug in the core since state and update time should change together. (Some might argue that the applies-from time should be part of the state...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm what do you think about this AI analysis?

https://claude.ai/share/009bca45-734b-4c29-9d25-eac0eba4291f

I was worried as so much of this happens asynchronously in corr

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a core bug to me. I'd guess the chances of one of the notify or event jobs getting scheduled, starting up and making "enough" progress before applyState sets the update time is pretty slim. But it does seem wrong.

See Core issue 5711 and PR#5712

ZonedDateTime time = (lastStateUpdate != null ? lastStateUpdate : ZonedDateTime.now());

logIfManyQueuedTasks();
if (!(item instanceof GenericItem)) {
Expand Down