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

Heimdall/PHP reads the sqlite database every 3 seconds while idle #1264

Open
tehinfidel opened this issue Jan 16, 2024 · 8 comments
Open

Heimdall/PHP reads the sqlite database every 3 seconds while idle #1264

tehinfidel opened this issue Jan 16, 2024 · 8 comments

Comments

@tehinfidel
Copy link

Hello,

Like many others probably, I run Heimdall as an internal service directory, in my case on a Raspberry Pi which services many basic network microservices and is backed up on a UPS to let it and my router/core switch keep running in a power outage for as long as possible.

In running fatrace to try to check on and reduce SD card IO, I discovered that Heimdall (linuxserver/heimdall:2.5.8 in a docker container, without the page loaded in my browser to rule out javascript or other client-side checks, and the stock homepage from a fresh install with exactly 0 customization) continuously reads the sqlite database every 3 seconds, increasing wear on the SD card. While I realize I can likely connect it to an external database over the network, keeping a homepage app self-contained is much more portable and .. well, self-contained.

I dug through the code and there are several timers running, but have not been able to isolate the process or need to read the database, especially every 3 seconds. I think it is in one of the vendor/* libraries included, or possibly resources/views/layouts/app.blade.php.

A better design pattern would be that something like inotify or equivalent be set up against the database to reread it on change and/or on demand when the page is loaded, and the service should be almost entirely idle when the page is not loaded or changes are being made.

Steps to reproduce:

  1. Perform a fresh install linuxserver/heimdall:2.5.8 in a Docker container. Do not load the page.
  2. Run fatrace -t and observe the following:
...
07:44:50.300250 php(21851): R   /docker/heimdall/config/www/app.sqlite
07:44:53.301403 php(21851): R   /docker/heimdall/config/www/app.sqlite
07:44:56.302643 php(21851): R   /docker/heimdall/config/www/app.sqlite
07:44:59.303833 php(21851): R   /docker/heimdall/config/www/app.sqlite
07:45:02.305062 php(21851): R   /docker/heimdall/config/www/app.sqlite
07:45:05.306289 php(21851): R   /docker/heimdall/config/www/app.sqlite
07:45:08.307301 php(21851): R   /docker/heimdall/config/www/app.sqlite
07:45:11.308269 php(21851): R   /docker/heimdall/config/www/app.sqlite
07:45:14.309319 php(21851): R   /docker/heimdall/config/www/app.sqlite
07:45:17.310408 php(21851): R   /docker/heimdall/config/www/app.sqlite
...
@LinuxServer-CI
Copy link

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

@KodeStar
Copy link
Member

Do you have any enhanced apps running?

@tehinfidel
Copy link
Author

tehinfidel commented Feb 17, 2024

Hello,

No, it is a bone stock Heimdall image installation (lscr.io/linuxserver/heimdall:2.5.8). I just re-created the issue on a stock rpi install and fresh pull below, without the page loaded.

Reproduction session log
user@pitest:/docker/heimdall $ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
user@pitest:/docker/heimdall $ raspinfo
System Information
------------------

Raspberry Pi 5 Model B Rev 1.0
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"

Raspberry Pi reference 2023-12-11
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 2acf7afcba7d11500313a7b93bb55a2aae20b2d6, stage2

Linux pitest 6.1.0-rpi7-rpi-2712 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux
Revision        : d04170
Serial          : 00052efa9b4f58d0
Model           : Raspberry Pi 5 Model B Rev 1.0
Throttled flag  : throttled=0x0
Camera          : vc_gencmd_read_response returned -1 error=1 error_msg="Command not registered"

user@pitest:/docker/heimdall $ cat docker-compose.yaml
version: "2.1"

services:
  heimdall:
    container_name: heimdall
    image: lscr.io/linuxserver/heimdall:2.5.8
    restart: always
    environment:
      - PUID=1001
      - PGID=1001
      - TZ=Etc/UTC
    volumes:
      - /docker/heimdall/config:/config
    ports:
      - "8080:80/tcp"
      - "8443:443/tcp"
user@pitest:/docker/heimdall $ docker-compose up -d
Pulling heimdall (lscr.io/linuxserver/heimdall:2.5.8)...
2.5.8: Pulling from linuxserver/heimdall
00bbf9c9837a: Pull complete
f3a49a85e687: Pull complete
fd3a0bb93880: Pull complete
85afcca2475a: Pull complete
fb9ff607e747: Pull complete
9d73bf1bff05: Pull complete
b906f68ce508: Pull complete
b84731eb542c: Pull complete
9c95d40bf6a4: Pull complete
Digest: sha256:ddcff39e55141568466a5365485d441a910df281538312813b1539fa8b7c0940
Status: Downloaded newer image for lscr.io/linuxserver/heimdall:2.5.8
Creating heimdall ... done
user@pitest:/docker/heimdall $ docker ps
CONTAINER ID   IMAGE                                COMMAND   CREATED         STATUS         PORTS                                                                            NAMES
7b0a81be038b   lscr.io/linuxserver/heimdall:2.5.8   "/init"   7 seconds ago   Up 7 seconds   0.0.0.0:8080->80/tcp, :::8080->80/tcp, 0.0.0.0:8443->443/tcp, :::8443->443/tcp   heimdall
user@pi:/docker/heimdall $ date ; sudo fatrace -t -s 300 ; date
Sat Feb 17 18:02:55 UTC 2024
18:02:56.471127 systemd-journal(110): W /var/log/journal/6c112a10a6d64b439428aba9579a3b90/user-1000.journal
18:02:58.047131 php(2439): R /docker/heimdall/config/www/app.sqlite
18:03:00.818764 busybox(2451): RC /var/lib/docker/overlay2/8fb6ad35533cf75ad87b4273174ba57f067972e334c494956e4781368829ff4b/diff/etc/crontabs
18:03:00.818764 busybox(2451): RC /var/lib/docker/overlay2/02cd4972014ceba3769ed2f96c30d38177bb33138ded7cbaecd810df9b1b3ce4/diff/etc/crontabs
18:03:01.047833 php(2439): R /docker/heimdall/config/www/app.sqlite
18:03:04.048472 php(2439): R /docker/heimdall/config/www/app.sqlite
18:03:07.049349 php(2439): R /docker/heimdall/config/www/app.sqlite
18:03:10.050207 php(2439): R /docker/heimdall/config/www/app.sqlite
18:03:13.051083 php(2439): R /docker/heimdall/config/www/app.sqlite
18:03:16.052002 php(2439): R /docker/heimdall/config/www/app.sqlite
18:03:19.052895 php(2439): R /docker/heimdall/config/www/app.sqlite
^CSat Feb 17 18:03:19 UTC 2024
user@pitest:/docker/heimdall $ docker kill heimdall
heimdall
user@pitest:/docker/heimdall $ docker container prune
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
7b0a81be038b7be84d0194e98630661f13432243e0dd6900a2282fc31bb6cd1b

Total reclaimed space: 51.58MB
user@pitest:/docker/heimdall $ sudo rm -rf config/* config/.??*
user@pitest:/docker/heimdall $ ls -al config/
total 8
drwxrwx--- 2 heimdall heimdall 4096 Feb 17 18:16 ./
drwxrwx--- 3 root     docker   4096 Feb 17 18:05 ../
user@pitest:/docker/heimdall $ vim docker-compose.yaml
user@pitest:/docker/heimdall $ cat docker-compose.yaml
version: "2.1"

services:
  heimdall:
    container_name: heimdall
    image: lscr.io/linuxserver/heimdall:latest
    restart: always
    environment:
      - PUID=1001
      - PGID=1001
      - TZ=Etc/UTC
    volumes:
      - /docker/heimdall/config:/config
    ports:
      - "8080:80/tcp"
      - "8443:443/tcp"

# EOF
user@pitest:/docker/heimdall $ docker-compose up -d
Pulling heimdall (lscr.io/linuxserver/heimdall:latest)...
latest: Pulling from linuxserver/heimdall
Digest: sha256:ddcff39e55141568466a5365485d441a910df281538312813b1539fa8b7c0940
Status: Downloaded newer image for lscr.io/linuxserver/heimdall:latest
Creating heimdall ... done
user@pitest:/docker/heimdall $ docker ps
CONTAINER ID   IMAGE                                 COMMAND   CREATED         STATUS         PORTS                                                                            NAMES
f2f8b99b6310   lscr.io/linuxserver/heimdall:latest   "/init"   8 seconds ago   Up 7 seconds   0.0.0.0:8080->80/tcp, :::8080->80/tcp, 0.0.0.0:8443->443/tcp, :::8443->443/tcp   heimdall
user@pitest:/docker/heimdall $ date ; sudo fatrace -t -s 300 ; date
Sat Feb 17 18:06:27 UTC 2024
18:06:27.721111 systemd-journal(110): W /var/log/journal/6c112a10a6d64b439428aba9579a3b90/user-1000.journal
18:06:29.930210 php(2948): R /docker/heimdall/config/www/app.sqlite
18:06:32.930847 php(2948): R /docker/heimdall/config/www/app.sqlite
18:06:35.931809 php(2948): R /docker/heimdall/config/www/app.sqlite
18:06:38.932934 php(2948): R /docker/heimdall/config/www/app.sqlite
18:06:41.933848 php(2948): R /docker/heimdall/config/www/app.sqlite
18:06:44.934872 php(2948): R /docker/heimdall/config/www/app.sqlite
18:06:47.935766 php(2948): R /docker/heimdall/config/www/app.sqlite
18:06:50.936709 php(2948): R /docker/heimdall/config/www/app.sqlite
18:06:53.937598 php(2948): R /docker/heimdall/config/www/app.sqlite
^CSat Feb 17 18:06:54 UTC 2024

The /docker/heimdall/config bind volume in the docker-compose.yml files above is an empty directory upon creation of the first container, as well as the second run against :latest, which is still actually lscr.io/linuxserver/heimdall:2.5.8; just checking if there had been any changes, but it appears the behavior is still present.

I've also just now separately recreated on a quickly spun-up ubuntu-22.04.4-LTS amd64 proxmox VM with lscr.io/linuxserver/heimdall:2.5.8 to rule out (unlikely) differences between architectures or host configs; same behavior with the php daemon reading the /docker/heimdall/config/www/app.sqlite every 3 seconds:

...
18:28:17.243917 php(919): R /docker/heimdall/config/www/app.sqlite
18:28:20.244537 php(919): R /docker/heimdall/config/www/app.sqlite
18:28:23.245431 php(919): R /docker/heimdall/config/www/app.sqlite
18:28:26.246324 php(919): R /docker/heimdall/config/www/app.sqlite
...

@LinuxServer-CI
Copy link

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

@tehinfidel
Copy link
Author

The issue still occurs. I am still trying to dig in to isolate the location of the timed reads; slow-going as I am not a PHP expert and have many other things on my plate at the moment.

@LinuxServer-CI
Copy link

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

@tehinfidel
Copy link
Author

Still occurs.

@LinuxServer-CI
Copy link

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Non-Docker Issues
Development

No branches or pull requests

3 participants