pi-hole / docker-pi-hole

Pi-hole in a docker container
https://pi-hole.net
Other
8.35k stars 1.12k forks source link

Pihole v6 takes more than 4 minutes to start on raspberry pi 3b #1622

Open rohitagre opened 1 month ago

rohitagre commented 1 month ago

This is a: Bug

Details

On restart of docker container, pihole loads queries from the long term database and it takes too long to finish this process. DNS resolution is unavailable during this time.

Related Issues

How to reproduce the issue

  1. Environment data

    • Operating System: Rasbian
    • Hardware: RasPi 3B
    • Kernel Architecture: aarch64
    • Docker Install Info and version:
    • Software source: Official Docker version 27.1.1, build 6312585
    • Supplimentary Software:
    • Hardware architecture:
  2. docker-compose.yml contents, docker run shell command, or paste a screenshot of any UI based configuration of containers here

    
    # More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
    services:
    pihole:
    image: pihole/pihole:development-v6
    container_name: pihole-v6
    environment:
      # Change the Web UI Password:
      - FTLCONF_webserver_api_password=password
      - TZ=Asia/Kolkata
      - FTLCONF_dns_listeningMode=all
      - VIRTUAL_HOST=pihole.lan
      - VIRTUAL_PORT=80
    dns:
      - 127.0.0.1
    volumes:
      - "/home/pi/portainer/pihole6/etc-pihole:/etc/pihole"
      - "/home/pi/portainer/pihole6/etc-dnsmasq.d:/etc/dnsmasq.d"
    ports:
      - "53:53/tcp"
      - "53:53/udp"
    restart: unless-stopped
    networks:
      work:
        ipv4_address: 10.10.20.3

networks: work: name: work external: true


3. any additional info to help reproduce

2024-08-07 10:54:57.725 IST [148M] INFO: ########## FTL started on 0022a4f6082d! ########## 2024-08-07 10:54:57.725 IST [148M] INFO: FTL branch: development-v6 2024-08-07 10:54:57.726 IST [148M] INFO: FTL version: vDev-7c00ea3 2024-08-07 10:54:57.726 IST [148M] INFO: FTL commit: 7c00ea38 2024-08-07 10:54:57.726 IST [148M] INFO: FTL date: 2024-07-29 18:17:47 +0200 2024-08-07 10:54:57.726 IST [148M] INFO: FTL user: pihole 2024-08-07 10:54:57.726 IST [148M] INFO: Compiled for linux/arm64/v8 (compiled on CI) using cc (Alpine 13.2.1_git20240309) 13.2.1 20240309 2024-08-07 10:54:59.036 IST [148M] INFO: 2 FTLCONF environment variables found (2 used, 0 invalid, 0 ignored) 2024-08-07 10:54:59.037 IST [148M] INFO: [✓] FTLCONF_dns_listeningMode is used 2024-08-07 10:54:59.037 IST [148M] INFO: [✓] FTLCONF_webserver_api_password is used 2024-08-07 10:54:59.043 IST [148M] INFO: Wrote config file: 2024-08-07 10:54:59.044 IST [148M] INFO: - 148 total entries 2024-08-07 10:54:59.044 IST [148M] INFO: - 134 entries are default 2024-08-07 10:54:59.044 IST [148M] INFO: - 14 entries are modified 2024-08-07 10:54:59.044 IST [148M] INFO: - 1 entry is forced through environment 2024-08-07 10:54:59.052 IST [148M] INFO: Parsed config file /etc/pihole/pihole.toml successfully 2024-08-07 10:54:59.053 IST [148M] WARNING: Insufficient permissions to set process priority to -10 (CAP_SYS_NICE required), process priority remains at 0 2024-08-07 10:54:59.060 IST [148M] INFO: PID of FTL process: 148 2024-08-07 10:54:59.063 IST [148M] INFO: listening on 0.0.0.0 port 53 2024-08-07 10:54:59.063 IST [148M] INFO: listening on :: port 53 2024-08-07 10:54:59.069 IST [148M] INFO: PID of FTL process: 148 2024-08-07 10:54:59.073 IST [148M] INFO: Database version is 19 2024-08-07 10:54:59.076 IST [148M] INFO: Database successfully initialized

2024-08-07 10:55:50.360 IST [148M] INFO: Imported 351284 queries from the on-disk database (it has 1374429 rows) 2024-08-07 10:55:50.360 IST [148M] INFO: Parsing queries in database 2024-08-07 10:55:51.877 IST [148M] INFO: 10000 queries parsed... 2024-08-07 10:55:54.079 IST [148M] INFO: 20000 queries parsed... 2024-08-07 10:55:57.003 IST [148M] INFO: 30000 queries parsed... 2024-08-07 10:56:00.652 IST [148M] INFO: 40000 queries parsed... 2024-08-07 10:56:04.362 IST [148M] INFO: 50000 queries parsed... 2024-08-07 10:56:09.718 IST [148M] INFO: 60000 queries parsed... 2024-08-07 10:56:15.251 IST [148M] INFO: 70000 queries parsed... 2024-08-07 10:56:20.512 IST [148M] INFO: 80000 queries parsed... 2024-08-07 10:56:26.032 IST [148M] INFO: 90000 queries parsed... 2024-08-07 10:56:31.627 IST [148M] INFO: 100000 queries parsed... 2024-08-07 10:56:38.287 IST [148M] INFO: 110000 queries parsed... 2024-08-07 10:56:44.929 IST [148M] INFO: 120000 queries parsed... 2024-08-07 10:56:51.075 IST [148M] INFO: 130000 queries parsed... 2024-08-07 10:56:57.060 IST [148M] INFO: 140000 queries parsed... 2024-08-07 10:57:02.521 IST [148M] INFO: 150000 queries parsed... 2024-08-07 10:57:08.473 IST [148M] INFO: 160000 queries parsed... 2024-08-07 10:57:15.285 IST [148M] INFO: 170000 queries parsed... 2024-08-07 10:57:22.252 IST [148M] INFO: 180000 queries parsed... 2024-08-07 10:57:29.829 IST [148M] INFO: 190000 queries parsed... 2024-08-07 10:57:36.276 IST [148M] INFO: 200000 queries parsed... 2024-08-07 10:57:43.524 IST [148M] INFO: 210000 queries parsed... 2024-08-07 10:57:49.280 IST [148M] INFO: 220000 queries parsed... 2024-08-07 10:57:57.731 IST [148M] INFO: 230000 queries parsed... 2024-08-07 10:58:05.275 IST [148M] INFO: 240000 queries parsed... 2024-08-07 10:58:13.886 IST [148M] INFO: 250000 queries parsed... 2024-08-07 10:58:22.101 IST [148M] INFO: 260000 queries parsed... 2024-08-07 10:58:29.510 IST [148M] INFO: 270000 queries parsed... 2024-08-07 10:58:39.272 IST [148M] INFO: 280000 queries parsed... 2024-08-07 10:58:48.068 IST [148M] INFO: 290000 queries parsed... 2024-08-07 10:58:55.903 IST [148M] INFO: 300000 queries parsed... 2024-08-07 10:59:03.794 IST [148M] INFO: 310000 queries parsed... 2024-08-07 10:59:12.703 IST [148M] INFO: 320000 queries parsed... 2024-08-07 10:59:19.649 IST [148M] INFO: 330000 queries parsed... 2024-08-07 10:59:31.265 IST [148M] INFO: 340000 queries parsed... 2024-08-07 10:59:42.556 IST [148M] INFO: 350000 queries parsed... 2024-08-07 10:59:42.821 IST [148M] INFO: Imported 350224 queries from the long-term database

2024-08-07 10:59:42.821 IST [148M] INFO: -> Total DNS queries: 350224 2024-08-07 10:59:42.822 IST [148M] INFO: -> Cached DNS queries: 129862 2024-08-07 10:59:42.822 IST [148M] INFO: -> Forwarded DNS queries: 51045 2024-08-07 10:59:42.822 IST [148M] INFO: -> Blocked DNS queries: 165277 2024-08-07 10:59:42.822 IST [148M] INFO: -> Unknown DNS queries: 11 2024-08-07 10:59:42.822 IST [148M] INFO: -> Unique domains: 5788 2024-08-07 10:59:42.822 IST [148M] INFO: -> Unique clients: 56 2024-08-07 10:59:42.822 IST [148M] INFO: -> DNS cache records: 24458 2024-08-07 10:59:42.823 IST [148M] INFO: -> Known forward destinations: 2 2024-08-07 10:59:42.847 IST [148M] WARNING: Insufficient permissions to set system time (CAP_SYS_TIME required), NTP client not available 2024-08-07 10:59:42.847 IST [148/T718] INFO: NTP server listening on 0.0.0.0:123 (IPv4) 2024-08-07 10:59:42.847 IST [148/T719] INFO: NTP server listening on :::123 (IPv6) 2024-08-07 10:59:42.848 IST [148M] INFO: FTL is running as user pihole (UID 100) 2024-08-07 10:59:42.849 IST [148M] INFO: Reading certificate from /etc/pihole/tls.pem ... 2024-08-07 10:59:42.850 IST [148M] INFO: Using SSL/TLS certificate file /etc/pihole/tls.pem 2024-08-07 10:59:43.446 IST [148M] INFO: Restored 1 API session from the database 2024-08-07 10:59:43.518 IST [148M] INFO: Blocking status is enabled 2024-08-07 10:59:43.565 IST [148/T720] INFO: Compiled 0 allow and 0 deny regex for 56 clients in 1.5 msec



I just hope i am not missing any configuration parameters which is causing this.

<img width="1511" alt="Screenshot 2024-08-07 at 11 50 14 AM" src="https://github.com/user-attachments/assets/c33cbe00-ec99-43d0-8683-cf9c446081be">

## These common fixes didn't work for my issue
<!-- IMPORTANT! Help me help you! Ordered with most common fixes first. -->
- [x] I have tried removing/destroying my container, and re-creating a new container
- [x] I have tried fresh volume data by backing up and moving/removing the old volume data
- [x] I have tried running the stock `docker run` example(s) in the readme (removing any customizations I added)
- [x] I have tried a newer or older version of Docker Pi-hole (depending what version the issue started in for me)
- [x] I have tried running without my volume data mounts to eliminate volumes as the cause

If the above debugging / fixes revealed any new information note it here.
Add any other debugging steps you've taken or theories on root cause that may help.
rdwebdesign commented 1 month ago

[x] I have tried running without my volume data mounts to eliminate volumes as the cause

Do you see the same 4 minutes even without the volumes?

rohitagre commented 1 month ago

I have removed the volumes and i am now waiting for the database to populate. i will report back in 1 day

rohitagre commented 1 month ago

Does not make any difference if i remove the Volumes. but i lose all customisations :( With Volumes : Time taken to load 60,000 queries : ~18 seconds Without Volumes : Time taken to load 60,000 queries : ~15 seconds

2024-08-08 17:58:39.417 IST [148M] INFO: Imported 69246 queries from the on-disk database (it has 69246 rows)
2024-08-08 17:58:39.417 IST [148M] INFO: Parsing queries in database
2024-08-08 17:58:40.164 IST [148M] INFO:   10000 queries parsed...
2024-08-08 17:58:41.918 IST [148M] INFO:   20000 queries parsed...
2024-08-08 17:58:44.137 IST [148M] INFO:   30000 queries parsed...
2024-08-08 17:58:46.744 IST [148M] INFO:   40000 queries parsed...
2024-08-08 17:58:49.189 IST [148M] INFO:   50000 queries parsed...
2024-08-08 17:58:52.047 IST [148M] INFO:   60000 queries parsed...
2024-08-08 17:58:54.955 IST [148M] INFO: Imported 69246 queries from the long-term database
2024-08-08 17:58:54.955 IST [148M] INFO:  -> Total DNS queries: 69246

I would also like to emphasise that pihole is running on a raspberry pi and it has only one SD card for all data, its not like docker volumes are on a different storage, so i don't think it should make any difference.

PromoFaux commented 1 month ago

Nothing to do with the slow loading, but these are not valid env vars:

      - VIRTUAL_HOST=pihole.lan
      - VIRTUAL_PORT=80

Two thoughts come to mind:

rohitagre commented 1 month ago

The env vars are for nginx proxy that I use for the web UI.

The SD card is class 10 and I am using official power supply for the pi.

$ sudo mmc csd read /sys/block/mmcblk0/device
type: 'SD'
card classes: 10 switch, 8 application specific, 7 lock card, 5 erase, 4 block write, 2 block read, 0 basic, 
capacity: 29.28Gbyte (31439454208 bytes, 61405184 sectors, 512 bytes each)

Speed test on SD card shows following

Write test

$ sudo dd if=/dev/zero of=./TestingFile bs=100M count=5 oflag=direct
5+0 records in
5+0 records out
524288000 bytes (524 MB, 500 MiB) copied, 40.99 s, 12.8 MB/s

Read test

$ sudo dd if=./TestingFile of=/dev/zero bs=100M count=5 oflag=dsync
5+0 records in
5+0 records out
524288000 bytes (524 MB, 500 MiB) copied, 23.0098 s, 22.8 MB/s
PromoFaux commented 1 month ago

Sorry, I mean to say they're not valid for v6. There is nothing inside the v6 container looking for those variables. I think there are equivalent proxy settings in FTL, though I do not have the documentation to hand right now.


I'll see if I can dig a 3b and a class 10 SD card out of my box of things and try to reproduce at some point - I have so far not experienced any such slow startup time, but then I am testing v6 on an x86 machine

rohitagre commented 1 month ago

Sorry I don't think I was clear in my previous reply.

Those environment variables are used by another container running nginx-proxy which helps me in assigning local DNS domains to my containers so I don't have to use multiple ports https://github.com/nginx-proxy/nginx-proxy

github-actions[bot] commented 1 week ago

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.

rohitagre commented 3 days ago

@github-actions bot please reopen this issue  😉