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

objects.jsonl slowly blowing up with growing debounce hash #2359

Closed
olifre opened this issue Feb 9, 2024 · 23 comments · Fixed by #2365
Closed

objects.jsonl slowly blowing up with growing debounce hash #2359

olifre opened this issue Feb 9, 2024 · 23 comments · Fixed by #2365

Comments

@olifre
Copy link

olifre commented Feb 9, 2024

Describe the bug
Since a few days, my objects.jsonl keeps growing and growing whenever I reconfigure parameters, causing adapters to use hundreds of megabytes of RAM.

Checking, I find:

# grep example_state objects.jsonl | tail -n1 | less
{"k":"0_userdata.0.example_state","v":{"_id":"0_userdata.0.example_state","type":"state","common":{"name":"Example state","role":"indicator","def":false,"type":"boolean","custom":{"history.0":{"enabled":true,"aliasId":"","debounceTime":0,"blockTime":500,"changesOnly":true,"changesRelogInterval":0,"changesMinDelta":0,"ignoreBelowNumber":"","disableSkippedValueLogging":false,"retention":0,"customRetentionDuration":365,"maxLength":5,"enableDebugLogs":false,"debounce":[0,[[0,[0,[0,[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"],[0,"10000"]

This hash appears to keep growing whenever I reconfigure history settings for the data point.

To Reproduce
Steps to reproduce the behavior:
Sadly, I am not fully sure whether this can be triggered as easily in any configuration... For me, it happens on each config change, i.e.:

  1. Enable history adapter.
  2. Configure history adapter for any data point.
  3. Adapt parameters in memory (maxLength) or debounce settings.
  4. Save.
  5. object.jsonl seems to grow, hash never shrinks for me.

Expected behavior
Hash to be trimmed at some point...

Screenshots & Logfiles
Maybe this is related to some unexpected configuration on my end? I can provide config if asked what to look for.

Versions:

  • Adapter version: 3.0.1
  • JS-Controller version: 5.0.17 (in official Docker container)
  • Node version: v18.19.0
  • Operating system: Official Docker container (Debian 12)
@Apollon77 Apollon77 transferred this issue from ioBroker/ioBroker.history Feb 9, 2024
@Apollon77
Copy link
Collaborator

Apollon77 commented Feb 9, 2024

In fact that the objects.jsonl is growing is completely fine because this is the idea of this fileformat. There are settings when this file gets "optimized" and rewritten to lower the filesize again. Normally the file gets "compressed" every 23h after ab start and because of other rules. You can manually compress it by running "iob fix".

How many Objects you have? (Admin shows this). Are you sure that no adapter creates new objects all the time? There were versions of ble that - whem discovery was turned on and many devices came by - it ended with many objects ...

@Apollon77
Copy link
Collaborator

Ahhhh ok now I see ... very strange ... debounce should just be a humber and nothing else ... I would more move to admin.

So please try the following:
1.) Turn off history for such a state, save ... check that in admin Objects with expert mode there is nothing in com on.custom ... then enable it again .. how it looks then?
2.) Make suere to use an updated Admin version

@foxriver76 any idea? That shpuld be a number and no array

@Apollon77 Apollon77 transferred this issue from ioBroker/ioBroker.js-controller Feb 9, 2024
@Apollon77
Copy link
Collaborator

PS: please also post the object json from the object system.adapter.history.0 (thank you)

@olifre
Copy link
Author

olifre commented Feb 9, 2024

Ahhhh ok now I see ... very strange ... debounce should just be a humber and nothing else ... I would more move to admin.

Indeed, now that I checked the code here, I'm also quite confused that this should be a completely different datatype, i.e. just a simple integer...

1.) Turn off history for such a state, save ... check that in admin Objects with expert mode there is nothing in com on.custom ... then enable it again .. how it looks then?

Then it does look fine, i.e.:

    "custom": {
      "history.0": {
        "enabled": true,
        "aliasId": "",
        "debounceTime": 0,
        "blockTime": 500,
        "changesOnly": true,
        "changesRelogInterval": "0",
        "changesMinDelta": 0,
        "ignoreBelowNumber": "",
        "disableSkippedValueLogging": false,
        "retention": "0",
        "customRetentionDuration": 365,
        "maxLength": 10,
        "enableDebugLogs": false,
        "debounce": 0
      }
    }

(only pasted the interesting custom part).

2.) Make suere to use an updated Admin version

I am using: v6.13.16.

One idea: I usually adjust objects in group, i..e. using the wrench after selecting a list of objects by searching for their name. Once I press the wrench icon, if the individual objects had individual settings (e.g. different blocktimes), I get a comma-separated list for that setting:

grafik

Creating two data points, setting different maxLength for them, matching them and editing them as a group, and then adjusting some value and saving leads to this:

        "maxLength": [
          10,
          [
            10,
            11
          ],
          11
        ],

Maybe something similar happend to me with debounce?

What I did to get this:

  1. Create two states with similar name, so they can easily be filtered on in the object view.
  2. Activate history on both.
  3. Use different maxLength for both (10 and 11).
  4. Use the "wrench" to adapt "history" settings for both, and change an unrelated setting (e.g. blocktime) and save.

So that's probably a bug in the admin adapter?

PS: please also post the object json from the object system.adapter.history.0 (thank you)

Leaving out the "boring" parts (let me know if you need them):

  "native": {
    "maxLength": 5,
    "limit": 2000,
    "storeDir": "/opt/iobroker/data/",
    "debounce": "10000",
    "retention": "0",
    "storeFrom": false,
    "storeAck": true,
    "changesRelogInterval": "0",
    "changesMinDelta": "0",
    "writeNulls": true,
    "blockTime": 0,
    "debounceTime": 0,
    "disableSkippedValueLogging": false,
    "enableLogging": false,
    "round": "",
    "customRetentionDuration": 365
  },
  "acl": {
    "object": 1636,
    "ownerGroup": "system.group.administrator"
  },
  "protectedNative": [],
  "encryptedNative": [],
  "instanceObjects": [],
  "objects": [],
  "notifications": [],
  "from": "system.adapter.admin.0",
  "user": "system.user.admin",
  "ts": 1707478179889

@olifre
Copy link
Author

olifre commented Feb 9, 2024

If I am correct, then the func for the hidden debounce field:

"customObj && customObj.common && customObj.common.type === 'number' ? instanceObj.native.debounce : 0",

will cause this to happen if adjusting history for any number and non-number state type and having a native debounce != 0, since this will always lead to different values which are then paired up, invisible to the user, since it is a hidden field (i.e. there is no "GUI" way to fix this, since the field is hidden). That probably caused those many pairs of "10000" and 0 I got, from editing a large set of states of mixed type in one go?

@Apollon77
Copy link
Collaborator

Thanks, I think the info with the wrench might help to reproduce

@foxriver76
Copy link
Collaborator

foxriver76 commented Feb 13, 2024

Yes it is basically reproduceable like filter for two objects, give one e.g. debounce of 100 other debounce of 200, then use wrench to modify both objects at once. Admin will then show a comma separated list because of the different values. If you then save again, admin will save this csv list into both.

See e.g. alias id or difference to last value

grafik

@olifre
Copy link
Author

olifre commented Feb 13, 2024

While showing the comma-separated list may be a feature (it's not fully clear what else admin may do), I believe that persisting the information (not matching the underlying "datatype") into every single data point is a bug.

The main problem in my example, though, is that this also happens with hidden fields (note that debounce is hidden with a value defaulted via a func, only debounceTime is visible). For hidden fields, the same thing happens, and the user can not correct it.

So a fix / change in behaviour needs to consider:

  • What to persist in case multiple items are selected, and a bulk change is triggered via the wrench — should the user be forced to decide for the fields containing lists, or should such fields be ignored?
  • What to do about hidden fields, which the user can't interact with?

@foxriver76
Copy link
Collaborator

After talking about it it seems with older admin versions we displayed different greyed out and only saved changes to such fields if user wrote something in it explicitly. Probably this is the best solution.

@Diginix
Copy link

Diginix commented Feb 14, 2024

Will the fix cleanup/alter already "destroyed" objects?
I had a lot of them in the past and always manually fixed this, but never had a clue what causes this.
So, would be nice to have all as expected after the bugfix without manually search in RAW json.

@foxriver76
Copy link
Collaborator

no, there is no automatic cleanup as it is not possible to identify the correct values, however there is now a dropdown which shows you which values are configured if you are in multi edit mode.

@Diginix
Copy link

Diginix commented Feb 14, 2024

Ok, then I have to search for the affected objects in objects.jsonl and manually fix them hopefully finaly.

@Diginix
Copy link

Diginix commented Feb 14, 2024

FYI: Not only debouce is affected:

    "custom": {
      "history.0": {
        "enabled": [
          false,
          true
        ],
        "aliasId": "",
        "debounceTime": 1000,
        "blockTime": 0,
        "changesOnly": true,
        "changesRelogInterval": [
          "0",
          0
        ],
        "changesMinDelta": 0,
        "ignoreBelowNumber": "",
        "disableSkippedValueLogging": true,
        "retention": 31536000,
        "customRetentionDuration": 365,
        "maxLength": 100,
        "enableDebugLogs": false,
        "debounce": [
          0,
          "1000"
        ],
        "ignoreZero": true
      }
    }

@foxriver76
Copy link
Collaborator

The fix is a general approach and not specific to one of the values

@olifre
Copy link
Author

olifre commented Feb 14, 2024

For the history adapter, the easiest fix is likely to disable the adapter on all datapoints and then re-enable. Since data is not purged (to my knowledge) when disabling, this cleans up the configuration (but of course this may be a lot of work if you have custom retention settings for groups of data points).

@foxriver76
Copy link
Collaborator

You can go in bulk edit mode, check where different values dropdown is shown and select a single new value here. Of course this will then apply this setting for all, but may be useful in some scenarios and less effort than reconfiguring every field

@Diginix
Copy link

Diginix commented Feb 14, 2024

For the history adapter, the easiest fix is likely to disable the adapter on all datapoints and then re-enable. Since data is not purged (to my knowledge) when disabling, this cleans up the configuration (but of course this may be a lot of work if you have custom retention settings for groups of data points).

For me no option. I have over 1200 objects with enabled history and many have different retention, debouce, changemindelta ...

@Apollon77
Copy link
Collaborator

@Diginix Then lets say it that way ... IF an object are affectet (at least in my assumption) then it woul fail back to the defaiuukt debounce/retention and such because ar array-data can not be parsed into a number so it will be invalid and so the instance default is used ... at least "should" ... so IF it is affected then your special set data (sorry) are lost there ...

@Diginix
Copy link

Diginix commented Feb 14, 2024

I will find all affected by looking for e.g "debounce":[ in objects.jsonl and the same for all other keys.
But I won't search/replace it in objects.json, even this would work after stopping iobroker. Instead I will edit all in admin object editor.
I'm happy that the cause is fixed now and then it is worth to fix the settings.

Found 52 wrong debounce, 25 wrong enabled and 9 wrong changesRelogInterval:
So, it isn't that much effort to fix it manually.

@olifre
Copy link
Author

olifre commented Feb 14, 2024

Let me know whether this should be reported as a new issue, but after updating to the new Admin release and trying this out by:

  1. Creating two data points:
    • 0_userdata.0.example_state
    • 0_userdata.0.example_state_2
  2. Activating history for both, but choosing debounceTime of 500 for the first, and 501 for the latter.
  3. Using the wrench for bulk modify.
  4. Then clicking on unterschiedlich / different, seeing the very useful new list, and choosing 500 there...

I get an Error in GUI!. Trace from console is below:

blockTime => 500 [console.ts:40:19](http://homeserv.fritz.box:8081/node_modules/@sentry/src/instrument/console.ts)
- unsubscribe 0_userdata.0.example_state [console.ts:40:19](http://homeserv.fritz.box:8081/node_modules/@sentry/src/instrument/console.ts)
- unsubscribe 0_userdata.0.example_state_2 [console.ts:40:19](http://homeserv.fritz.box:8081/node_modules/@sentry/src/instrument/console.ts)
TypeError: w.getValue(...) is not iterable
    renderItem ConfigNumber.tsx:129
    render ConfigGeneric.tsx:917
    React 10
        Po
        No
        Ei
        ks
        ys
        vs
        us
        ss
        Hl
        ls

This is with admin v6.13.20.

@foxriver76
Copy link
Collaborator

I will have a look tomorrow @olifre

@foxriver76
Copy link
Collaborator

6.13.21 should fix it.

@olifre
Copy link
Author

olifre commented Feb 15, 2024

@foxriver76 Many thanks for the quick fix, I can confirm 👍 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants