Closed bleomycin closed 2 years ago
I am able to reproduce this error. Most likely caused after my commit from #56. However, this error does not seeming appear to be interfering with account creation or general application experience.
Any ideas on why database "docker" is being referenced?
The name of the db is written down in librephotos.env. This file should be renamed to .env
The name docker is usually the dbUser name. This error happens every five seconds, so my guess would be, that the error is somewhere here: https://github.com/LibrePhotos/librephotos-docker/blob/09dbe057444481dc1aca004073bbafda90f3a71e/docker-compose.yml#L38
I've been trying to implement different ways for the wait function to not be recalled upon successful initialization of the database.
So far I have had no luck. I do not know why the pg_isready is not able to connect to the database with the correct username. It seems as though it can't find the DB within the container. Even when 2022-07-07 21:50:08.294 UTC [1] LOG: database system is ready to accept connections
This is with 'librephotos.env' being changed to '.env'.
Again to note in my previous comment, this error does not seem to impact functionality nor usage. The pg_isready command is not ending after the database is setup. The 'test:' is somehow working as intended to delay the backend startup.
The question is: why is the test not ending?
I'm sorry I can't be more helpful other than to add that while I'm unsure if it is related I did notice that performance seemed extremely slow when scanning new photos to the database of this fresh installation. By extremely slow I mean only processing a few photos a minute on an AMD ryzen 5600g processor with 64GB ram on all ssd storage.
"Docker go up, Docker go down"
I do not have enough knowledge of docker containers to be able to properly diagnose this issue fully. It does seem like a .sh script will need to be implemented in some way as shown in the proof-of-concept #41.
If anyone could show me channels to learn about "setting up a wrapper script" I would appreciate it. I tried a crude setup for wait-for-it but was not able to figure out how to path to ./wait-for-it.sh or where the code would go within the existing repo.
Using: https://docs.docker.com/compose/startup-order/
Such that:
command: ["./wait-for-it.sh", "db:5432", "--", "python", "app.py"]
would check for a databse.
Or as in the second example:
command: ["./wait-for-postgres.sh", "db", "python", "app.py"]
would do the same with a shorter script file.
(I am assuming in each, python & app.py is not needed in this case)
Other:
https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist https://github.com/docker-library/postgres/issues/146 https://gist.github.com/roylee0704/b5c8090e6cbfe1a9ae6c63062623a7cd#file-dockergrep-sh https://github.com/docker-library/postgres/issues/880 https://github.com/docker/compose/issues/8154 https://stackoverflow.com/questions/55762806/in-this-simple-docker-wrapper-script-example-how-may-one-correctly-pass-a-curre
I did notice that performance seemed extremely slow when scanning new photos to the database of this fresh installation.
@bleomycin Could you at all copy the backend and db docker logs here to see if it's related?
After looking into it for another day, nada. Here are somethings I was looking into.
https://www.howtogeek.com/devops/how-and-why-to-add-health-checks-to-your-docker-containers/ https://stackoverflow.com/questions/16931244/checking-if-output-of-a-command-contains-a-certain-string-in-a-shell-script https://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container
https://stackoverflow.com/questions/31887258/get-docker-container-names https://frightanic.com/computers/docker-default-container-names/ https://stackoverflow.com/questions/31887258/get-docker-container-names https://docker-docs.uclv.cu/engine/reference/commandline/exec/
(Extremely messy code)
#! /bin/sh
#test code 1
if docker exec -it db pg_isready -U docker | grep -q '/var/run/postgresql:5432 - accepting connections';
then
echo "0"
else
echo "1"
fi
#test code 2
set -e
host="$1"
shift
until psql -h "$dbHost" -U "$dbUser" -c '\q'; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
>&2 echo "Postgres is up - executing command"
exec "$@"
I played around with it too. GitHub Copilot suggested a valid alternative that works :D Would be great if you could confirm, if it works on your system too.
(edit:) @derneuere I see the commit, testing out now.
Error is gone! Thank you!
As for performance in response to @bleomycin: 100 photos scanned within 3 minutes. Default config, gtx 1080ti sc2, R7 2700X, 32gb ram, regular ssd. For some odd reason my "things" album doesn't seem to be showing thumbnails even though I can still search for the terms. However, if I change to a different directory with only 2 photos instead of 100 they do appear.
100 photos scan:
2 photos scan:
With the latest unmodified docker-compose.yml and librephotos.env files, on debian 11 with docker version 20.10.17, build 100c701. Following the instructions here exactly: https://docs.librephotos.com/1/standard_install/ yields the following endlessly repeating database error from the db container: FATAL: database "docker" does not exist