Peristance and restoreonstartup how to debug

I’m running OH3.2.0.M4 but I had the same results with previous AH3 versions
I want to use mapdb for restoreonstartup. For this I created rrd4j.persist


Strategies {
    // for rrd charts, we need a cron strategy
    elkeMin : "0 * * * * ?"
}

Items {
    // persist items on every change and every minute
    * : strategy = everyChange, elkeMin
} 
and mapdb.persist
Strategies {

    everyMinute : "0 * * * * ?"
}

Items {    

    *  : strategy = everyChange, restoreOnStartup
}

After a restart of OH3 I still get some wrong values back. How can I debug this.
I tested this by writing the values to the log file before I restart OH3 and compare them with the values after restart.

Examples? We don’t know what you think is “wrong”. (Poorly configured Quantity type Items can give you restore surprises by wrong factoring)

You can interrogate your mapdb from the REST API to see what it holds.

Thanks. Very informative to use REST API.
It doesn’t explain the results I get.

Number:Energy               ElectraLeveringPerDag           "Lev./dag [%.3f kWh]"           <energy>   (BG_Meterkast)      ["Measurement","Power"] { widgetOrder = "-1"} 

Number:Energy               ElectraLeveringPerMaandReference "mLRef [%.3f kWh]" 

I find a correct value for ElectraLeveringPerDag in mapdb and influxdb and not in rrd4j
value mapdb
“time”: 1658061600008,
“state”: “12.503999999998996”
value influxdb (only last value and is a bit lower?)
“time”: 1658061486387,
“state”: “12.388999999999214”
value rrd4j
“name”: “ElectraLeveringPerDag”,
“datapoints”: “0”,
“data”: []
But I can visualize the data ??
and for ElectraLeveringPerMaandReference I don’t get any value
mapdb
“name”: “ElectraLeveringPerMaandReference”,
“datapoints”: “0”,
“data”: []
influxdb
“name”: “ElectraLeveringPerMaandReference”,
“datapoints”: “0”,
“data”: []
rrd4j
“error”: {
“http-code”: 500,
“exception”: {
“class”: “java.lang.NullPointerException”
}
}
The types of both values are the same

We don’t know what you queried for, from REST API.
If I recall, rrd4j is a bit special (because of its time pigeonholes archive structure) and I think you have to be explicit about asking e.g. last 8 hours.
But that’s not relevant as you are not using it for restore (you hope).

First off, have you restarted since you last edited any xxx.persist files? This an area essentially inherited from OH1 and I would not trust for changes to
picked up dynamically, in-flight.

Next let’s look at the obvious-

Have you seen a change of state for that Item in your events.log?

So far as I can see, you have correctly defined a default unit for your Quantity type Item, so that should be working okay.

To be 100% sure I will do this during the weekend again and provide a update afterward.

I did a restart of OH. I saved the the values in the log file just before I did the restart. The good news is that all values got a new value. The bad news is that some are not correct. See below.
The italic lines are from the logfile just before the reboot. The bold values are wrong. I see that Italic and bold are not working one * is Italic and 3 *** is Italic and bold. Is it possible that the values are not coming from mapdb but from rrd4j and could this explain the issue?

                                                                                    ***GasPDref: 6271.583 ㎥** GasPWref: 6270.064 ㎥* GasPMref: 6264.971 ㎥ GasPJref: 5546.426 ㎥
           2022-07-23 07:51:31.782 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GasPerDagReference' changed from NULL to 6271.415 ㎥
           2022-07-23 07:51:31.107 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GasPerWeekReference' changed from NULL to 6270.064 ㎥
           2022-07-23 07:51:36.149 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GasPerMaandReference' changed from NULL to 6264.971 ㎥
           2022-07-23 07:51:34.711 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GasPerJaarReference' changed from NULL to 5546.426 ㎥
                      
                                                                                    ***levPDref: 15738.601 kWhVerPDref: 13322.789*** kWh
           2022-07-23 07:51:34.385 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElectraLeveringPerDagReference' changed from NULL to 15653.164 kWh 
           2022-07-23 07:51:34.499 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElectraVerbruikPerDagReference' changed from NULL to 13317.375 kWh
           
                                                                                    ***levPWref: 15653.164 kWh** VerPWref: 13274.403 kWh*
           2022-07-23 07:51:34.476 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElectraLeveringPerWeekReference' changed from NULL to 15541.397 kWh
           2022-07-23 07:51:33.699 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElectraVerbruikPerWeekReference' changed from NULL to 13274.403 kWh
                                                                                    
                                                                                    *levPMref: 15382.635 kWh VerPMref: 13199.942* kWh
           2022-07-23 07:51:31.474 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElectraLeveringPerMaandReference' changed from NULL to 15382.635 kWh
           2022-07-23 07:51:34.242 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElectraVerbruikPerMaandReference' changed from NULL to 13199.942 kWh
                                                                                    
                                                                                    *levPJref: 13097.64 kWh VerPJref: 11741.671 kWh*
           2022-07-23 07:51:34.692 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElektraLeveringPerJaarReference' changed from NULL to 13097.64 kWh 
           2022-07-23 07:51:31.902 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElektraVerbruikPerJaarReference' changed from NULL to 11741.671 kWh
           
                                                                                    ***abWref: 98.71*** 
           2022-07-23 07:51:32.245 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElectraAbsoluutPerWeekReference' changed from NULL to 53.311 kWh
                                                                                    
                                                                                    ***abMref: 174.09*** 
           2022-07-23 07:51:34.944 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElectraAbsoluutPerMaandReference' changed from NULL to 75.351 kWh
           
                                                                                    ***abJref: 912.148*** 
           2022-07-23 07:51:33.682 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ElectraAbsoluutPerJaarReference' changed from NULL to 900.756 kWh           

                                                                                    *SMAPWDref: 18413 kWh SMAPMref: 18058 kWh SMAPJref: 15022 kWh*
           2022-07-23 07:51:36.566 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'SMAPerWeekReference' changed from NULL to 18413 kWh           
           2022-07-23 07:51:32.707 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'SMAPerMaandReference' changed from NULL to 18058 kWh
           2022-07-23 07:51:36.402 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'SMAPerJaarReference' changed from NULL to 15022 kWh

Seems to be working in general. Are the values you are worried about only changing infrequently, daily or something?

Your strategy for MapDB is to persist on change.
Item states can be initialized at boot up by bindings before persistence is running. In that case, there won’t be a change to persist until tomorrow.

Give your MapDB a time-based persist as well, so that doesn’t arise.