/api/server-info/ping doesn't check connection to postgres #3380

Closed
opened 2026-02-05 08:13:52 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @dani on GitHub (May 30, 2024).

The bug

I'm using Immich on a Nomad orchestrator, and using /api/server-info/ping endpoint to check server's health. A regularly have an issue where connection to postgres times out (the initial problem is likely due to my system which is slowed down during backup, but Immich server is not reconnecting correctly to postgres, and always report a timeout even if the postgres server is working correctly once backups ended). When the postgres connection is down, /api/server-info/ping is still reporting an OK status, so my orchestrator cannot detect something is wrong, and restart Immich automatically

The OS that Immich Server is running on

Docker (on Nomad orchestrator)

Version of Immich Server

v1.105.1

Version of Immich Mobile App

v1.104.0

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

Not using docker-compose, but a Nomad job (https://git.lapiole.org/nomad/immich/src/branch/master/example/immich.nomad.hcl)

Your .env content

REDIS_HOSTNAME=127.0.0.1
IMMICH_MEDIA_LOCATION=/data
LANG=fr_FR.utf8
NODE_OPTIONS=--max-old-space-size=512
TZ=Europe/Paris
HTTP_PROXY=http://immich:XXXX@127.0.0.1:3128
HTTPS_PROXY=http://immich:XXXX@127.0.0.1:3128
DB_URL=postgres://immich:XXXX@127.0.0.1:5432/immich

Reproduction steps

1. Have postgres not reachable
2. Query /api/server-info/ping

Relevant log output

When Immich can't reach postgres, I see these kind of error

2024-05-30 09:05:34.000	    at process.processTimers (node:internal/timers:514:7)
2024-05-30 09:05:34.000	    at listOnTimeout (node:internal/timers:573:17)
2024-05-30 09:05:34.000	    at Timeout._onTimeout (/usr/src/app/node_modules/pg-pool/index.js:205:27)
2024-05-30 09:05:34.000	Error: timeout exceeded when trying to connect
2024-05-30 09:05:34.000	[Nest] 7  - 30/05/2024 09:05:34   ERROR [ImmichServer] [ExceptionsHandler] timeout exceeded when trying to connect
2024-05-30 09:05:39.000	"GET /api/user/me HTTP/1.1" 500 - 0 52 10005 10004 "10.99.20.2" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" "8e9d4f07-e874-4c5c-a16b-e15bf397205a" "photos.consul" "127.0.0.1:3001"
2024-05-30 09:05:44.000	    at Timeout._onTimeout (/usr/src/app/node_modules/pg-pool/index.js:205:27)
2024-05-30 09:05:44.000	    at process.processTimers (node:internal/timers:514:7)] Error: timeout exceeded when trying to connect
2024-05-30 09:05:44.000	    at process.processTimers (node:internal/timers:514:7)] Failed to get server config
2024-05-30 09:05:44.000	[Nest] 7  - 30/05/2024 09:05:44   ERROR [ImmichServer] [Error: timeout exceeded when trying to connect
2024-05-30 09:05:44.000	    at listOnTimeout (node:internal/timers:573:17)

I don't know why Immich "think" there's a timeout because postgres is reachable and correctly working. But anyway, the health endpoint should report something is wrong. As you can see a call to /api/user/me responds with a 500 error (when a user tries to access the web interface)



### Additional information

_No response_
Originally created by @dani on GitHub (May 30, 2024). ### The bug I'm using Immich on a Nomad orchestrator, and using /api/server-info/ping endpoint to check server's health. A regularly have an issue where connection to postgres times out (the initial problem is likely due to my system which is slowed down during backup, but Immich server is not reconnecting correctly to postgres, and always report a timeout even if the postgres server is working correctly once backups ended). When the postgres connection is down, /api/server-info/ping is still reporting an OK status, so my orchestrator cannot detect something is wrong, and restart Immich automatically ### The OS that Immich Server is running on Docker (on Nomad orchestrator) ### Version of Immich Server v1.105.1 ### Version of Immich Mobile App v1.104.0 ### Platform with the issue - [X] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML Not using docker-compose, but a Nomad job (https://git.lapiole.org/nomad/immich/src/branch/master/example/immich.nomad.hcl) ``` ### Your .env content ```Shell REDIS_HOSTNAME=127.0.0.1 IMMICH_MEDIA_LOCATION=/data LANG=fr_FR.utf8 NODE_OPTIONS=--max-old-space-size=512 TZ=Europe/Paris HTTP_PROXY=http://immich:XXXX@127.0.0.1:3128 HTTPS_PROXY=http://immich:XXXX@127.0.0.1:3128 DB_URL=postgres://immich:XXXX@127.0.0.1:5432/immich ``` ### Reproduction steps ```bash 1. Have postgres not reachable 2. Query /api/server-info/ping ``` ### Relevant log output ```shell When Immich can't reach postgres, I see these kind of error 2024-05-30 09:05:34.000 at process.processTimers (node:internal/timers:514:7) 2024-05-30 09:05:34.000 at listOnTimeout (node:internal/timers:573:17) 2024-05-30 09:05:34.000 at Timeout._onTimeout (/usr/src/app/node_modules/pg-pool/index.js:205:27) 2024-05-30 09:05:34.000 Error: timeout exceeded when trying to connect 2024-05-30 09:05:34.000 [Nest] 7 - 30/05/2024 09:05:34 ERROR [ImmichServer] [ExceptionsHandler] timeout exceeded when trying to connect 2024-05-30 09:05:39.000 "GET /api/user/me HTTP/1.1" 500 - 0 52 10005 10004 "10.99.20.2" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" "8e9d4f07-e874-4c5c-a16b-e15bf397205a" "photos.consul" "127.0.0.1:3001" 2024-05-30 09:05:44.000 at Timeout._onTimeout (/usr/src/app/node_modules/pg-pool/index.js:205:27) 2024-05-30 09:05:44.000 at process.processTimers (node:internal/timers:514:7)] Error: timeout exceeded when trying to connect 2024-05-30 09:05:44.000 at process.processTimers (node:internal/timers:514:7)] Failed to get server config 2024-05-30 09:05:44.000 [Nest] 7 - 30/05/2024 09:05:44 ERROR [ImmichServer] [Error: timeout exceeded when trying to connect 2024-05-30 09:05:44.000 at listOnTimeout (node:internal/timers:573:17) ``` I don't know why Immich "think" there's a timeout because postgres is reachable and correctly working. But anyway, the health endpoint should report something is wrong. As you can see a call to /api/user/me responds with a 500 error (when a user tries to access the web interface) ``` ### Additional information _No response_
Author
Owner

@bo0tzz commented on GitHub (May 30, 2024):

/ping isn't really a healthcheck endpoint, it's just hardcoded to return "pong"

@bo0tzz commented on GitHub (May 30, 2024): /ping isn't really a healthcheck endpoint, it's just hardcoded to return "pong"
Author
Owner

@brandonkal commented on GitHub (Aug 17, 2024):

Is there a healthcheck endpoint?

@brandonkal commented on GitHub (Aug 17, 2024): Is there a healthcheck endpoint?
Author
Owner

@bo0tzz commented on GitHub (Aug 17, 2024):

No, but iirc there is an open request for adding one and we would like to at some point.

@bo0tzz commented on GitHub (Aug 17, 2024): No, but iirc there is an open request for adding one and we would like to at some point.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#3380