postgresql log about no existing database - postgresql

I don't understand this postgresql log :
2022-03-27 08:00:19.441 UTC [584262] postgres#boutique2 FATAL: database "boutique2" does not exist
2022-03-27 08:00:19.704 UTC [584264] postgres#boutique2 FATAL: database "boutique2" does not exist
2022-03-27 08:01:54.770 UTC [781] LOG: received fast shutdown request
2022-03-27 08:01:54.773 UTC [781] LOG: aborting any active transactions
2022-03-27 08:01:54.779 UTC [781] LOG: background worker "logical replication launcher" (PID 800) exited with exit code 1
2022-03-27 08:01:54.780 UTC [795] LOG: shutting down
2022-03-27 08:01:54.797 UTC [781] LOG: database system is shut down
2022-03-27 08:02:16.254 UTC [770] LOG: starting PostgreSQL 13.5 (Debian 13.5-0+deb11u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-03-27 08:02:16.255 UTC [770] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-03-27 08:02:16.256 UTC [770] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-03-27 08:02:16.271 UTC [772] LOG: database system was shut down at 2022-03-27 08:01:54 UTC
2022-03-27 08:02:16.285 UTC [770] LOG: database system is ready to accept connections
2022-03-27 08:02:17.243 UTC [891] postgres#boutique2 FATAL: database "boutique2" does not exist
2022-03-27 08:02:17.640 UTC [1044] postgres#boutique2 FATAL: database "boutique2" does not exist
I dropped this database, which is not present in my mojolicious scripts, the only ones on this server.
root#perso:/etc/postgresql/13/main# grep postgresql.conf -e 'boutique2'
root#perso:/etc/postgresql/13/main# grep pg_hba.conf -e 'boutique2'
root#perso:/etc/postgresql/13/main#
Has please someone an idea about ?

Related

PostgreSQL not starting in time

I have restored a backup from psql server A to psql server B. When the postgresql service starts on server B, the log below is produced. From what I read the invalid record length message is not a problem, just an indicator that the end of the last WAL file was reached.
However, when I attempt to run 'psql' it gives a fatal error that the database is starting up. (I waited over an hour and still in that state). I still can't run psql. Note that standby.signal file is present on B, in case that matters.
What does this mean, and how do I fix it? Or is this normal while the standby.signal file is present?
2022-10-18 16:50:47.953 EDT [126144] LOG: starting PostgreSQL 13.5 (Debian 13.5-0+deb11u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-10-18 16:50:47.954 EDT [126144] LOG: listening on IPv6 address "::1", port 5432
2022-10-18 16:50:47.954 EDT [126144] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-10-18 16:50:47.955 EDT [126144] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-10-18 16:50:47.963 EDT [126145] LOG: database system was shut down in recovery at 2022-10-18 16:50:47 EDT
2022-10-18 16:50:48.052 EDT [126145] LOG: entering standby mode
2022-10-18 16:50:48.142 EDT [126145] LOG: redo starts at 0/70000028
2022-10-18 16:50:48.142 EDT [126145] LOG: invalid record length at 0/700000D8: wanted 24, got 0
pg_ctl: server did not start in time
2022-10-18 16:52:16.600 EDT [126876] postgres#postgres FATAL: the database system is starting up

invalid length of startup packet docker postgressql

PostgreSQL init process complete; ready for start up.
2022-05-16 19:28:51.674 UTC [1] LOG: starting PostgreSQL 14.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20211027) 10.3.1 20211027, 64-bit
2022-05-16 19:28:51.674 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2022-05-16 19:28:51.674 UTC [1] LOG: listening on IPv6 address "::", port 5432
2022-05-16 19:28:51.677 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-05-16 19:28:51.681 UTC [51] LOG: database system was shut down at 2022-05-16 19:28:51 UTC
2022-05-16 19:28:51.684 UTC [1] LOG: database system is ready to accept connections
2022-05-16 19:29:07.610 UTC [59] LOG: invalid length of startup packet
2022-05-16 19:29:07.611 UTC [58] LOG: invalid length of startup packet
2022-05-16 19:29:07.612 UTC [60] LOG: invalid length of startup packet
2022-05-16 19:29:08.647 UTC [62] LOG: invalid length of startup packet
2022-05-16 19:29:08.650 UTC [61] LOG: invalid length of startup packet
2022-05-16 19:29:08.652 UTC [63] LOG: invalid length of startup packet
Any help would be appreciated I couldn't figure out
Docker composer file
version: '3.9'
services:
postgres:
image: postgres:14-alpine
ports:
- 5432:5432
volumes:
- ~/apps/postgres:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=S3cret
- POSTGRES_USER=citizix_user
- POSTGRES_DB=citizix_db
Using ubuntu 20.4
Something, probably a monitoring system, is establishing TCP connections to the database server, then closing them without sending a correct PostgreSQL connection packet.
You can include %h in your log_line_prefix to see the client address of these connections, which may help identify the culprit.
The solution is to get the monitoring system to establish a database connection rather than only a TCP connection. Not only will that get rid of the message, but it will make the test much more useful.

postgresql running in docker compose doesn't create role

I am trying to run postgreSQL via docker-compose and I am getting the issue that user/password is not created when I started the service.
version: "3"
services:
db:
image: postgres:latest
container_name: postgres
#volumes:
#- postgres-data:/var/lib/postgresql/data
ports:
- 5432:5432
environment:
- POSTGRES_PASSWORD=postgrespassword
- POSTGRES_USER=postgres
- POSTGRES_DB=random_db_name
restart: always
I have this block of code in my docker-compose.yml and I run the following command:
docker-compose up -d (this allow me to start the service in background)
and when I check the logs I got:
docker logs -f 0e1731f95396
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
pg_ctl -D /var/lib/postgresql/data -l logfile start
waiting for server to start....2021-04-27 16:20:44.592 UTC [49] LOG: starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2021-04-27 16:20:44.594 UTC [49] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-04-27 16:20:44.603 UTC [50] LOG: database system was shut down at 2021-04-27 16:20:44 UTC
2021-04-27 16:20:44.609 UTC [49] LOG: database system is ready to accept connections
done
server started
CREATE DATABASE
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
waiting for server to shut down...2021-04-27 16:20:44.889 UTC [49] LOG: received fast shutdown request
.2021-04-27 16:20:44.891 UTC [49] LOG: aborting any active transactions
2021-04-27 16:20:44.892 UTC [49] LOG: background worker "logical replication launcher" (PID 56) exited with exit code 1
2021-04-27 16:20:44.892 UTC [51] LOG: shutting down
2021-04-27 16:20:44.907 UTC [49] LOG: database system is shut down
done
server stopped
PostgreSQL init process complete; ready for start up.
2021-04-27 16:20:45.018 UTC [1] LOG: starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2021-04-27 16:20:45.019 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2021-04-27 16:20:45.019 UTC [1] LOG: listening on IPv6 address "::", port 5432
2021-04-27 16:20:45.023 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-04-27 16:20:45.029 UTC [77] LOG: database system was shut down at 2021-04-27 16:20:44 UTC
2021-04-27 16:20:45.034 UTC [1] LOG: database system is ready to accept connections
But when I try to connect to this database locally I get the message: "FATAL: role "postgres" does not exist"
Do you have any input about how to solve this problem?
I already made a few attempts after reading a few comments from different places but I got always the same problem.
I was expecting to run locally postgreSQL and setup already a user/password and a Database with that name in the docker-compose

Postgresql wont start

Postgresql wont start in ubuntu 16.04,
Please give support.
These are the error log read:
2018-10-12 13:42:34 UTC [3371-2] LOG: received fast shutdown request
2018-10-12 13:42:34 UTC [3371-3] LOG: aborting any active transactions
2018-10-12 13:42:34 UTC [3376-2] LOG: autovacuum launcher shutting down
2018-10-12 13:42:34 UTC [3373-1] LOG: shutting down
2018-10-12 13:42:34 UTC [3373-2] LOG: database system is shut down
2018-10-12 13:42:52 UTC [3855-1] LOG: database system was shut down at
2018-10-12 13:42:34 UTC
2018-10-12 13:42:52 UTC [3855-2] LOG: MultiXact member wraparound
protections are now enabled
2018-10-12 13:42:52 UTC [3853-1] LOG: database system is ready to accept
connections
2018-10-12 13:42:52 UTC [3859-1] LOG: autovacuum launcher started
2018-10-12 13:42:52 UTC [3861-1] [unknown]#[unknown] LOG: incomplete
startup
packet

Postgres image is not creating database

According to these docs, I can specify the name of the database created by the postgres docker image with the env var POSTGRES_DB. I have set it in my docker-compose file, but it isn't being created.
Here's relevant section from the compose file:
pg:
image: postgres:10
volumes:
- db-data:/var/lib/postgresql/data
environment:
POSTGRES_DB: user-auth
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Here are the logs:
Attaching to userauth_pg_1
pg_1 | 2018-02-05 18:05:54.803 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
pg_1 | 2018-02-05 18:05:54.803 UTC [1] LOG: listening on IPv6 address "::", port 5432
pg_1 | 2018-02-05 18:05:54.806 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
pg_1 | 2018-02-05 18:05:54.817 UTC [24] LOG: database system was interrupted; last known up at 2018-02-05 18:03:26 UTC
pg_1 | 2018-02-05 18:05:54.942 UTC [24] LOG: database system was not properly shut down; automatic recovery in progress
pg_1 | 2018-02-05 18:05:54.944 UTC [24] LOG: redo starts at 0/1633ED0
pg_1 | 2018-02-05 18:05:54.944 UTC [24] LOG: invalid record length at 0/1633F08: wanted 24, got 0
pg_1 | 2018-02-05 18:05:54.944 UTC [24] LOG: redo done at 0/1633ED0
pg_1 | 2018-02-05 18:05:54.955 UTC [1] LOG: database system is ready to accept connections
pg_1 | 2018-02-05 18:05:59.140 UTC [31] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:06:15.528 UTC [32] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:08:46.120 UTC [33] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:08:46.151 UTC [34] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:02.138 UTC [35] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:02.926 UTC [36] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:04.244 UTC [37] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:04.273 UTC [38] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:04.602 UTC [39] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:04.910 UTC [40] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:05.777 UTC [41] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:05.823 UTC [42] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:05.878 UTC [43] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:06.663 UTC [44] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:14:06.716 UTC [45] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:16:32.713 UTC [46] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:47:04.603 UTC [47] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 18:51:34.413 UTC [1] LOG: received smart shutdown request
pg_1 | 2018-02-05 18:51:34.417 UTC [1] LOG: worker process: logical replication launcher (PID 30) exited with exit code 1
pg_1 | 2018-02-05 18:51:34.419 UTC [25] LOG: shutting down
pg_1 | 2018-02-05 18:51:34.434 UTC [1] LOG: database system is shut down
pg_1 | 2018-02-05 19:08:42.934 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
pg_1 | 2018-02-05 19:08:42.934 UTC [1] LOG: listening on IPv6 address "::", port 5432
pg_1 | 2018-02-05 19:08:42.937 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
pg_1 | 2018-02-05 19:08:42.951 UTC [25] LOG: database system was shut down at 2018-02-05 18:51:34 UTC
pg_1 | 2018-02-05 19:08:42.956 UTC [1] LOG: database system is ready to accept connections
pg_1 | 2018-02-05 19:09:04.316 UTC [32] FATAL: database "user-auth" does not exist
pg_1 | 2018-02-05 19:09:18.081 UTC [33] FATAL: database "user-auth" does not exist
You most probably started the container without the env variables set.
The db was then initialized without user or DB info.
You need to delete the volume and try again.
Credit: https://github.com/docker-library/postgres/issues/453#issuecomment-393939412
You can always initialize scripts for your database before running the container that if even in case you want to add multiple users or create tables initially inside of your container. a basic script would be like :
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE DATABASE database_name;
CREATE USER new_user_name WITH ENCRYPTED PASSWORD 'new_password';
GRANT ALL PRIVILEGES ON DATABASE new_user_name TO database_nam;
EOSQL
and can be saved as a shell file (init_db.sh for example).
Make sure at last to copy the file from your relative directory to the container by adding it to the docker-compose.yml file :
services:
db:
image: postgres:latest
ports:
- '4020:5432'
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- ./init_db.sh:/docker-entrypoint-initdb.d/init_db.sh
In my case, I've already had PostgreSQL working in the background on windows. And when I tried to connect to the docker container, I connected to my windows Postgres. You need to open services.msc and turn off PostreSQL
I was using devcontainer (Python 3 & PostgreSQL) in Visual Studio Code and sqltools.connections settings in devcontainer.json were overriding the configuration in docker-compose.yml.
I changed the settings there too and it worked as expected!
If you are using the Docker application you should delete the existing container and install it again with the command:
docker run --name containerName -p 5432:5432 -e POSTGRES_PASSWORD=postgresql -e POSTGRES_USER=postgresql -e POSTGRES_DB=dbName -d postgres
docker system prune
Adding this removed previous database settings of docker. Then ran again the pipeline after cleanup.