Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item value no more persisted => problem in persistence strategy loading ? #3617

Closed
lolodomo opened this issue May 17, 2023 · 17 comments · Fixed by #3618
Closed

Item value no more persisted => problem in persistence strategy loading ? #3617

lolodomo opened this issue May 17, 2023 · 17 comments · Fixed by #3618
Assignees
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@lolodomo
Copy link
Contributor

lolodomo commented May 17, 2023

I have a persisted switch item (RRD4j).
This item is linked to nothing, it is used as a parameter for my rules.
When I restart OH, its value is not restored (I see nothing in events.log).
It was set to OFF using UI before stopping OH.

It is with snapshot 3470 but I believe the problem appeared in previous snapshots.

As there were only one change regarding RRD4j (making the service writing asynchronously to DB), I suspect that change.

@lolodomo lolodomo added the bug An unexpected problem or unintended behavior of the Core label May 17, 2023
@lolodomo lolodomo changed the title [rrd4j] Item value not restored after a restart [rrd4j] Item value not restored after a restart OR persistence strategy no more loaded May 17, 2023
@lolodomo
Copy link
Contributor Author

@J-N-K : could it be rather your PR #2871 that would have broken the loading of the persistence strategy ?
After enabling RRD4J DEBUG logs, I see that my item is no more persisted while it is of course defined in my persistence strategy (file rrd4j.persist). That would explain why restore on startup is not done.

@J-N-K
Copy link
Member

J-N-K commented May 17, 2023

Can you show the .persist file?

@lolodomo
Copy link
Contributor Author

lolodomo commented May 17, 2023

File unchanged since a very very long time:

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
	// for rrd charts, we need a cron strategy
	everyMinute : "0 * * * * ?"
}

Items {
	GTemperature*, GSuiviConsoElec* : strategy = everyChange, everyMinute, restoreOnStartup
	GVirtualData*, GParametres* : strategy = everyChange, restoreOnStartup
}

And the item no more persisted is EnConges :

Group All "Toutes catégories" <none>
Group GPersist "Données stockées" <none> (All)
Group GParametres "Paramètres" <settings> (GPersist)
Switch EnConges "En congés" (GParametres)

I have removed the file and I am restarting OH to be sure that the RRD file is not created again.

@lolodomo lolodomo changed the title [rrd4j] Item value not restored after a restart OR persistence strategy no more loaded [rrd4j] Item value no more persisted => persistence strategy no more loaded ? May 17, 2023
@lolodomo
Copy link
Contributor Author

I see my temperatures in GTemperature* persisted every minute, so at least a part of my persistence strategy is loaded.

@J-N-K
Copy link
Member

J-N-K commented May 17, 2023

So "everyChange" is not working?

@lolodomo
Copy link
Contributor Author

lolodomo commented May 17, 2023

I see that storing every minute for GTemperature* and GSuiviConsoElec* is done.
And storing on change is also working for GTemperature*.
But not for items in GParametres.
I will check if storing is done for an item in GVirtualData.

@lolodomo
Copy link
Contributor Author

lolodomo commented May 17, 2023

Items in GVirtualData are also stored !
Only my two items in GParametres are apparently no more working. They are Switch items. Could it be something broken for switch items only ?
Was there a recent update of rrd4j library ?

@lolodomo lolodomo changed the title [rrd4j] Item value no more persisted => persistence strategy no more loaded ? [rrd4j] Item value no more persisted => broken for switch items ? May 17, 2023
@lolodomo
Copy link
Contributor Author

lolodomo commented May 17, 2023

Either store is no more called or store is now returning null.
In the method, I see the following code (unchanged):

        if (item instanceof NumberItem && item.getState() instanceof QuantityType) {
...
        } else {
            DecimalType state = item.getStateAs(DecimalType.class);
            if (state != null) {
                value = state.toBigDecimal().doubleValue();
            } else {
                value = null;
            }
        }

        if (value == null) {
            // we could not convert the value
            return;
        }

Was there a change in what return item.getStateAs(DecimalType.class) for a switch item ?

I will have to add logs in this method to be sure.

@J-N-K
Copy link
Member

J-N-K commented May 17, 2023

It seems to be an RRD4J issue, because it works with InfluxDB

@lolodomo
Copy link
Contributor Author

lolodomo commented May 17, 2023

Ok, after adding more traces, I can tell you that store method from RRD4j persistence service is simply no more called for these switch items.
So that looks like a problem in core framework, in the handling of persistence strategy ?

@lolodomo
Copy link
Contributor Author

lolodomo commented May 17, 2023

@J-N-K : are you sure it is not the new PersistenceManager with the filter stuff. The problem is probably in method handleStateEvent.

@J-N-K
Copy link
Member

J-N-K commented May 17, 2023

No, but I just created a new Item SwitchPersist which is a member of GSwitchGroup. I then created an influxdb.persist`

trategies {
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
    default = everyChange, restoreOnStartup
}

Items {
    everyMinutePersistance*             : strategy = everyMinute, restoreOnStartup
    everyHourPersistance*               : strategy = everyHour, restoreOnStartup
    everyDayPersistance*                : strategy = everyHour, restoreOnStartup
    NewItem 		 	        : strategy = everyChange, everyHour, restoreOnStartup
    Timeseries_Updates_Forecast         : strategy = forecast
    GSwitchGroup* : strategy = everyChange
}

and I see every change in my influxdb.

@lolodomo
Copy link
Contributor Author

I can restore the snapshot 3440 which I think was a build from the third of May and certainly before your PR was merged and see if it works again ?

@lolodomo
Copy link
Contributor Author

I can also try to change the group of my switch item to move it in GVirtualData as I see that Number items in that group are persisted. That could help to understand if the problem is the group or the item type ?

@lolodomo
Copy link
Contributor Author

lolodomo commented May 17, 2023

I can also try to change the group of my switch item to move it in GVirtualData as I see that Number items in that group are persisted. That could help to understand if the problem is the group or the item type ?

Interesting, if I change the group of my item (from GParametres to GVirtualData) , then it works !

22:45:19.527 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'EnConges' received command ON
22:45:19.536 [TRACE] [rd4j.internal.RRD4jPersistenceService] - Store method called for item 'EnConges' of type 'Switch' with value 'ON'
22:45:19.540 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'EnConges' changed from NULL to ON
22:45:19.541 [TRACE] [rd4j.internal.RRD4jPersistenceService] - item 'EnConges' getStateAs(DecimalType.class) '1'
22:45:19.548 [TRACE] [rd4j.internal.RRD4jPersistenceService] - item 'EnConges' value '1.0'
22:45:19.557 [TRACE] [rd4j.internal.RRD4jPersistenceService] - Using rrd definition 'default_other = GAUGE heartbeat = 3600 min/max = NaN/NaN step = 5 4 archives(s) = [ LAST xff = 0.5 steps = 1 rows = 720 LAST xff = 0.5 steps = 12 rows = 10080 LAST xff = 0.5 steps = 180 rows = 35040 LAST xff = 0.5 steps = 2880 rows = 21900] 0 items(s) = []' for item 'EnConges'.
22:45:19.615 [DEBUG] [rd4j.internal.RRD4jPersistenceService] - Stored 'EnConges' as value '1.0' with timestamp 1684356319 in rrd4j database

So, apparently, the second "group" of this line is now ignored ?

GVirtualData*, GParametres* : strategy = everyChange, restoreOnStartup

@lolodomo
Copy link
Contributor Author

If I replace in my file rrd4j.persist this line

        GVirtualData*, GParametres* : strategy = everyChange, restoreOnStartup

by

        // GVirtualData*, GParametres* : strategy = everyChange, restoreOnStartup
        GVirtualData* : strategy = everyChange, restoreOnStartup
        GParametres* : strategy = everyChange, restoreOnStartup

Now it works for my items in group GParametres.

So there is certainly something broken in the handling of these lines when there are more than one group ?

@J-N-K
Copy link
Member

J-N-K commented May 17, 2023

That's strange, because I don't remember having changed something there, but I'll check that.

@lolodomo lolodomo changed the title [rrd4j] Item value no more persisted => broken for switch items ? [rrd4j] Item value no more persisted => problem in persistence strategy loading ? May 17, 2023
@J-N-K J-N-K transferred this issue from openhab/openhab-addons May 18, 2023
@J-N-K J-N-K self-assigned this May 18, 2023
@J-N-K J-N-K changed the title [rrd4j] Item value no more persisted => problem in persistence strategy loading ? Item value no more persisted => problem in persistence strategy loading ? May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants