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

InfluxDB Persistence not working anymore in 3.1.0-M3 build #10464

Closed
aMU5Ed opened this issue Apr 4, 2021 · 22 comments · Fixed by #10680
Closed

InfluxDB Persistence not working anymore in 3.1.0-M3 build #10464

aMU5Ed opened this issue Apr 4, 2021 · 22 comments · Fixed by #10680
Labels
bug An unexpected problem or unintended behavior of an add-on
Milestone

Comments

@aMU5Ed
Copy link

aMU5Ed commented Apr 4, 2021

I'm using OH 3.1.0 M3 build on Ubuntu 20.04 LTS 64bit on Raspberry Pi 4 (8GB RAM) and Azul Embedded Java 64Bit. With M2 sumSince calculations ware working well like "SM_PV_EigenverbrauchGesamt.postUpdate(SM_PV_EigenverbrauchTag.sumSince(parse("2021-01-01T00:00+01:00[Europe/Vienna]")) as Number". Since OH3 the item name is written as Tag in the Influx DB (version 1.8). Caluclations (with values that have a tag or not) are working in M2. With M3 the calculations only sum up the values that have the Item name stored as tag in InfluxDB. I do not have any tags configured in my OH Persitence config. Also charts do not show the values (which are not used in the sumSince calculation).
Log says: 2021-04-04 15:26:18.493 [INFO ] [b.internal.InfluxDBStateConvertUtils] - Could not find item 'null' in registry

@cweitkamp cweitkamp transferred this issue from openhab/openhab-core Apr 4, 2021
@ole-elo
Copy link

ole-elo commented Apr 8, 2021

I have the same issue here. It is possible to solve it by manually add the "item" tags to influxdb. In my case this is a lot of manual work, because I have a lot in influx.
Is there any "repair" or "migrate" function available? Would it be possible to use the _measurement value if no "item" tag is available as fallback in the influx addon?

@aMU5Ed
Copy link
Author

aMU5Ed commented Apr 8, 2021

@ole-elo Unfortunatly I do not have any work around. I just downgraded to M2 and it started to work as expected. Hopefully there will be a fix for M4 or release.
@cweitkamp you removed the issue from openhab-core. Which component would be the correct one?

@cweitkamp
Copy link
Contributor

The add-on org.openhab.persistence.influxdb is located in this repository: org.openhab.persistence.influxdb. Thus the issue belongs here.

The cause for your issue may be related to the latest changes: #9943

@aMU5Ed
Copy link
Author

aMU5Ed commented Apr 9, 2021

@cweitkamp thanks for the hint. Seems that this change could be the root cause. Hoepfully this gets fixed in M4!

@J-N-K
Copy link
Member

J-N-K commented Apr 11, 2021

Is this still true after a new value has been stored? I'm usinf .M3 and don't see these issues

@aMU5Ed
Copy link
Author

aMU5Ed commented Apr 12, 2021

@J-N-K 7one exampe: values stored in the influx measurement: 1,2,3 without item tag 4,5,6 with item tag. M2: will sum up 1+2+3+4+5+6 M3 will sum up only 4+5+6

@J-N-K
Copy link
Member

J-N-K commented Apr 17, 2021

I can reproduce that now. But the issue must be much older than M3. I need to use data that is older than 150 days to get your issues.

FTR:

logInfo("Test 30", WEZ_hum.sumSince(now.minusDays(30), "influxdb").toString)
logInfo("Test 60", WEZ_hum.sumSince(now.minusDays(60), "influxdb").toString)
logInfo("Test 90", WEZ_hum.sumSince(now.minusDays(90), "influxdb").toString)
logInfo("Test 120", WEZ_hum.sumSince(now.minusDays(120), "influxdb").toString)
logInfo("Test 150", WEZ_hum.sumSince(now.minusDays(150), "influxdb").toString)
logInfo("Test 180", WEZ_hum.sumSince(now.minusDays(180), "influxdb").toString)

Only the last line produces the fault, that's why I didn't see it before (I only tried last 60 days, which is much more than M3).

@microneer
Copy link

I've upgraded directly from 2.5.12 to 3.1.0M3 and OH charts don't show any data from before the upgrade.

Am I right that sometime between 2.5.12 and 3.1.0M3, OH started adding data to influxdb with the Item name as a tag? This is an example of what I see:

> show series from Bathroom_Humidity
key
---
Bathroom_Humidity
Bathroom_Humidity,item=Bathroom_Humidity

So I think the problem is more general than rule calculations: 3.1.0M3 just isn't accessing any legacy series without the item= part. In my case, that's everything up till the day before yesterday.

@microneer
Copy link

@cweitkamp, I think you're right about it being introduced in #9943. @DerOetzi, I believe the issue lies with lines 60 and 66 of Influx1FilterCriteriaQueryCreatorImpl.java in cdd99c9.

        Select select = select().column("\"" + COLUMN_VALUE_NAME_V1 + "\"::field")
                .column("\"" + TAG_ITEM_NAME + "\"::tag")
                .fromRaw(null, fullQualifiedTableName(retentionPolicy, tableName, hasCriteriaName));

        Where where = select.where();

        if (itemName != null && !tableName.equals(itemName)) {
            where = where.and(BuiltQuery.QueryBuilder.eq(TAG_ITEM_NAME, itemName));
        }

Until cdd99c9 there was no mention of tags in the query. Adding the tag to the query means that historic data is being filtered out?

I'm at the limit of my abilities here, not really able to actually fix it, sorry.

@brevilo
Copy link

brevilo commented Apr 26, 2021

Should this be added to the 3.1 issue list now that the feature itself (#9943) is going to be released with 3.1?

@aMU5Ed
Copy link
Author

aMU5Ed commented May 5, 2021

Should this be added to the 3.1 issue list now that the feature itself (#9943) is going to be released with 3.1?

That would be nice. Actually I am in a dead end with M2 until a fix is ready on that issue

@cweitkamp cweitkamp added the bug An unexpected problem or unintended behavior of an add-on label May 6, 2021
@Intenos
Copy link

Intenos commented May 11, 2021

I have the same issue and would appreciate a fix as well.

@wborn wborn added this to the 3.1 milestone May 12, 2021
@wborn
Copy link
Member

wborn commented May 12, 2021

Can you have a look at this @DerOetzi or @lujop?

@lujop
Copy link
Contributor

lujop commented May 12, 2021

I will try to take a look.
@microneer Can you enable trace log level for the org.openhab.persistence.influxdb and append the query that is send to InfluxDB

@J-N-K
Copy link
Member

J-N-K commented May 12, 2021

Please see my post above. The problem is not the query but how the response is handled.

@lujop
Copy link
Contributor

lujop commented May 12, 2021

Please see my post above. The problem is not the query but how the response is handled.

@J-N-K I'm not sure without reproducing it. Because althought your suggested changes are cleaner I think that they do exactly the same as the current code.
Because in current code when columnName is not found it uses the itemName variable that was previously set.

if (itemNameColumn != null) {
itemName = (String) valuess.get(i).get(itemNameColumn);
}

@lujop
Copy link
Contributor

lujop commented May 12, 2021

Excuse me @J-N-K I've just seen it just after writing the comment. I didn't realize the requireNonNullElse

@J-N-K
Copy link
Member

J-N-K commented May 12, 2021

No, it does not.

@lujop
Copy link
Contributor

lujop commented May 12, 2021

I will make a PR with J-N-K suggested change, it looks good to me but I will do a small check.
The problem is with data that was written with InfluxDB addon before the 3.0.0 version that didn't set the item tag name.

lujop added a commit to lujop/openhab-addons that referenced this issue May 12, 2021
Fix problem with historical  Influx1 data that was generated with addon version <3.0.0 that didn't write generate item tag
Signed-off-by: Joan Pujol <joanpujol@gmail.com>
@lujop
Copy link
Contributor

lujop commented May 12, 2021

If someone is able to test I attached a binary in that PR #10680
I tried to simulate in an InfluxDB 1.0 but better if someone with the problem can confirm.

@Intenos
Copy link

Intenos commented May 13, 2021

Hi lujop,
Very great, that did it for me. It works. Thanks a lot for the fast fix.

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 an add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants