Influxdb fails after openhabian reboot

Over the past weeks I had several issues with influxdb and openHAB wasn’t able to access influx anymore. Finally I at least found out how to fix it which

sudo chown -R 1000:1000 /var/lib/influxdb
sudo chown -R influxdb:influxdb /var/lib/influxdb
sudo systemctl daemon-reload
sudo systemctl restart influxdb.service

Now, I found out what causes the problem: it is a server restart of my raspbi4 which runs openHAB 3.4.1

Does anyone have an idea why the server restart creates the problem which I can fix by the above statements? (for the record, an openHAB restart does not result into the problem)

If you execute these two lines after an other

the first one is obsolete/unnecessary.

Is ZRAM turned on ? I had a similar problem when I was installing mosquitto some time ago.
For whatever reason ( at least in my case ) the underlying entries on filesystem did not get the changes done in ZRAM file layer.
I would suggest to have a look into folders, files in /opt/zram/*.bind/ and check the ownerships and permissions in those directories if they match with what they need to be.

true :man_facepalming:

Yes, it is.

this is what it looks like

/opt/zram/influxdb.bind $ ls -l
drwxr-xr-x 3 influxdb influxdb 4096 Jan  7 12:00 data
drwxr-xr-x 2 influxdb influxdb 4096 Jan 30 00:34 meta
drwx------ 3 influxdb influxdb 4096 Jan  7 12:00 wal

That does look good at least now.

If say /var/lib/influxdb is on ZRAM on your box, when ZRAM starts after a reboot, it’ll take the ‘real’ files+dirs+permission from /var/lib/influxdb which is on SD at that time and ‘replaces’ the directory with itself. The original SD directory will from then on be available as /opt/zram/something.bind. I suggest you change the permissions in there, too.
The problem usually is when you install something with ZRAM on then boot without letting ZRAM sync back to SD. It does on stopping the zram service which is part of any proper shutdown but will not work when there’s a power outage.
And if your problem relates to right the “root” dir of a ZRAM mount this is certainly a special edge case and changes aren’t synced even on proper shutdown. I would not know how to handle this.

Thx Markus, for the explanation.

These are the permissions of /var/lib/influxdb:

drwxr-xr-x 1 influxdb influxdb 4096 Jan  7 12:00 data
-rw-r--r-- 1 influxdb influxdb    5 Feb  5 10:36
drwxr-xr-x 1 influxdb influxdb 4096 Jan 30 00:34 meta
drwx------ 1 influxdb influxdb 4096 Jan  7 12:00 wal

to me they look identical.

I don’t understand what you mean here, though.

Any further idea that I could investigate?

I will do a reboot tomorrow and see what the permissions are after the reboot and then post that here (I don’t dare to do that now).

The dir itself /var/lib/influxdb if that is the zram mountpoint on your box.