MySQL persistence -- some Number items not persisted on change

I’m running OH2.2 via a Docker container on Linux (FC24).
I recently configured persistence using MySQL, and noticed that some of my Items are not being persisted on change.

Here’s my mysql.persist:
// persistence strategies have a name and a definition and are referred to in the “Items” section
Strategies {
// if no strategy is specified for an item entry below, the default list will be used
everyMinute : "0 * * * * ?"
every5Minutes : "0 */5 * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
default = everyChange

 * Each line in this section defines for which item(s) which strategy(ies) should be applied.
 * You can list single items, use "*" for all items or "groupitem*" for all members of a group
 * item (excl. the group item itself).

Items {
    // persist all items once a day and on every change and restore them from the db at startup
    * : strategy = everyChange, everyDay, restoreOnStartup

    // additionally, persist all temperature and weather values every hour
    //   gTemperatur* : strategy = every5Minutes, restoreOnStartup

# the database url like ‘jdbc:mysql://:/’ (without quotes)

# the database user

# the database password

# the reconnection counter

# the connection timeout (in seconds)

# Use MySQL Server time to store item values (=false) or use openHAB Server time (=true).
# For new installations, its recommend to set "localtime=true".
# (optional, defaults to false)

A sample Item:
Number Outdoor_Temp "Outdoor Temp [%.0f]" <temperature> (Outdoor, Temperature, Outdoor_TempChart) {mqtt="<[mqtt87:/env/temp/garden:state:JS(mqtt_var.js)]"}

From MySQL, I see the valie was persisted once when I enabled Persistence, and a second time at midnight (per the everyDay rule applied to all items):

mysql> select * from Items where ItemName="Outdoor_Temp";
| ItemId | ItemName     |
|     18 | Outdoor_Temp |
1 row in set (0.00 sec)

mysql> select * from Item18;
| Time                | Value |
| 2018-02-16 22:01:35 |    34 |
| 2018-02-17 00:00:01 |    32 |
2 rows in set (0.00 sec)

However, there were numerous changes reported that were never persisted:

$ grep Outdoor_Temp /opt/openhab2/userdata/logs/events.log
2018-02-16 22:01:34.747 [vent.ItemStateChangedEvent] - Outdoor_Temp changed from 35 to 34
2018-02-16 22:17:31.160 [ome.event.ItemUpdatedEvent] - Item 'Outdoor_Temp' has been updated.
2018-02-16 22:17:34.774 [vent.ItemStateChangedEvent] - Outdoor_Temp changed from NULL to 34
2018-02-16 22:23:22.692 [ome.event.ItemUpdatedEvent] - Item 'Outdoor_Temp' has been updated.
2018-02-16 22:23:34.755 [vent.ItemStateChangedEvent] - Outdoor_Temp changed from NULL to 34
2018-02-16 22:34:34.787 [vent.ItemStateChangedEvent] - Outdoor_Temp changed from 34 to 33
2018-02-16 22:35:34.783 [vent.ItemStateChangedEvent] - Outdoor_Temp changed from 33 to 34
2018-02-16 22:36:34.765 [vent.ItemStateChangedEvent] - Outdoor_Temp changed from 34 to 33
2018-02-16 23:23:34.946 [vent.ItemStateChangedEvent] - Outdoor_Temp changed from 33 to 32

(this continues through the current time, 2018-02-17 19:20:35.320).

The UI shows the value noted in events.log, but charts only reflect what we see in MySql (as you’d expect).
Does the MQTT binding apply a different type of change that’s not noted by the everyChange strategy?
I’m seeing this with multiple items. I’m not 100% sure, but the pattern suggests it may be related to the Number type – I have Dimmers and Swtiches that are also updated via MQTT, and they seem to be working as expected (although not interesting to chart…)
I also have rules that trigger on these Items (via Item xxx received update) that are working correctly.

Appreciate any hints. I’ve read quite a few persistence-related posts, but haven’t found any that touched on this issue.

Are you using the mysql binding or jdbc binding?

I have used both and had no issues with retaining number item changes.

Perhaps you should turn up logging on your mysql persistence binding and see if there are any other clues?

No. A change is a change. So long as you see item changed from x to y… everychange in persistence should apply. Your log suggests a valid change and I would expect them to be persisted as you expect.

mysql binding or jdbc binding?

persistence-mysql - 1.11.0

I think this may have corrected itself after an OH restart.

Good, glad to hear!

If it gives you more trouble, you could try the jdbc version as well. I migrated to it when I upgraded from 1.8 to 2.1. I don’t recall all of the reasons now but I felt like it was a step up for some reason :slight_smile:

Thanks. So far, it seems OK since the restart (which I did for another reason, but happy to see the improvement here). I’ll keep the jdbc version in mind.