Skip to content

Conversation

@willnode
Copy link

@willnode willnode commented Jul 7, 2024

Added a health check so the service can heal from crashing by itself.

@ruslandoga
Copy link
Contributor

👋 @willnode

How does it compare to #83? I'm afraid that setup would make the startup too slow (>30 seconds)

@willnode
Copy link
Author

willnode commented Jul 7, 2024

The healthcheck for the clickhouse is the recommended way of doing health check. Wait I'll benchmark it on my live server.

@ruslandoga
Copy link
Contributor

ruslandoga commented Jul 7, 2024

The healthcheck for the clickhouse is the recommended way of doing health check.

Seems to be just a (possibly outdated) StackOverflow answer. Is there any official source recommending this exact approach? I'd think clickhouse client would be recommended now.

@willnode
Copy link
Author

willnode commented Jul 7, 2024

I'm afraid that setup would make the startup too slow (>30 seconds)

I can add these parameters (if you OK with fairly new docker compose requirement to 2.20 if i'm not mistaken)

    healthcheck:
      test: ...
      start_interval: 2s
      start_period: 1m

The startup from last down is like this now:

$ time docker compose up -d --wait
[+] Running 4/4
 ✔ Network public_html_default                  Created            0.1s
 ✔ Container public_html-plausible_db-1         Healthy            3.7s
 ✔ Container public_html-plausible_events_db-1  Healthy            3.7s
 ✔ Container public_html-plausible-1            Healthy           22.2s

real    0m22.428s
user    0m0.149s
sys     0m0.089s

If --wait omitted the startup would only need 3.7s

Is there any official source recommending this exact approach?

https://clickhouse.com/docs/en/interfaces/http

In health-check scripts use GET /ping request.

But both works and I see no difference in timing anyway.

@ruslandoga
Copy link
Contributor

I can add these parameters

Yes, please do :)

@willnode
Copy link
Author

willnode commented Jul 7, 2024

Added

@ruslandoga
Copy link
Contributor

ruslandoga commented Jul 16, 2024

👋 @willnode

I tried it on my instance for the last week, and all was great. Thank you!

@ruslandoga
Copy link
Contributor

ruslandoga commented Aug 2, 2024

👋 @willnode

Sorry to bother you, but it seems like pg_isready is using root user, can you please verify? Should we edit the healthcheck to use $PG_USER or whatever it is? Or should we express the command as a list ["CMD", "pg_isready"], I remember there were some differences between that expression and a string which uses the shell, and possibly that's where the root user is coming from.

...
plausible_db-1  | 2024-08-02 10:35:25.439 UTC [575826] FATAL:  role "root" does not exist
plausible_db-1  | 2024-08-02 10:35:55.557 UTC [575835] FATAL:  role "root" does not exist
plausible_db-1  | 2024-08-02 10:36:25.681 UTC [575841] FATAL:  role "root" does not exist
plausible_db-1  | 2024-08-02 10:36:55.798 UTC [575849] FATAL:  role "root" does not exist
...

I'm reverting this PR for now to avoid confusing new users with these scary looking errors.

@ruslandoga
Copy link
Contributor

ruslandoga commented Aug 2, 2024

Related to #146, but it's unlikely to be the cause.

ruslandoga added a commit that referenced this pull request Aug 2, 2024
@willnode
Copy link
Author

willnode commented Aug 3, 2024

Hello, sorry this change bothering you. I should really checking it from ground zero.

Here's my exact setup I currently use. I use docker rootless setup though I'm skeptical it has any difference. Maybe the version difference could be the cause?

  plausible_db:
    image: postgres:12-alpine
    restart: always
    volumes:
      - ./db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=postgres
    healthcheck:
      test: pg_isready
      start_interval: 2s
      start_period: 1m

@BtbN
Copy link

BtbN commented Aug 8, 2024

This should be pretty easy to fix by just adding -U postgres to the pg_isready invocation.

@willnode willnode deleted the add-healthcheck branch June 24, 2025 11:57
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 this pull request may close these issues.

3 participants