Postgresql error : PANIC: could not locate a valid checkpoint record - postgresql

In the Datastore logs, I encountered the following error, Not sure what has gone wrong.
[7804] LOG: starting PostgreSQL 13.1, compiled by Visual C++ build 1914, 64-bit
2021-08-23 22:56:15.980 CEST [7804] LOG: listening on IPv4 address "127.0.0.1", port 9003
2021-08-23 22:56:15.983 CEST [7804] LOG: listening on IPv4 address "10.91.198.36", port 9003
2021-08-23 22:56:16.041 CEST [8812] LOG: database system was shut down at 2021-08-23 22:54:51 CEST
2021-08-23 22:56:16.044 CEST [8812] LOG: invalid primary checkpoint record
2021-08-23 22:56:16.045 CEST [8812] PANIC: could not locate a valid checkpoint record
2021-08-23 22:56:16.076 CEST [7804] LOG: startup process (PID 8812) was terminated by exception 0xC0000409
2021-08-23 22:56:16.076 CEST [7804] HINT: See C include file "ntstatus.h" for a description of the hexadecimal value.
2021-08-23 22:56:16.078 CEST [7804] LOG: aborting startup due to startup process failure
2021-08-23 22:56:16.094 CEST [7804] LOG: database system is shut down

Somebody deleted crucial WAL files (to free space?), and now your cluster is corrupted
Restore from backup. If you have no backup, running pg_resetwal is an option, since it seems there was a clean shutdown.

Related

Postgres-15.1 is restarting continuously on using shared_preload_libraries extension

Postgres is restarting continuously on using shared_preload_libraries extension.
https://postgresqlco.nf/doc/en/param/shared_preload_libraries/
I am running postgres-15.1 using a python-based daemon in CentOS7-32bit arch. It is working fine if we do not use "shared_preload_libraries" extension. But after enabling this extension using "ALTER SYSTEM SET shared_preload_libraries" command, the postgres is restarting every few seconds.
Initially it was working fine with postgres-9.6.4.
Postgres logs:
waiting for server to start....2023-02-15 07:13:45.676 GMT [28605] LOG: skipping missing configuration file "/home/runtime/pgsql/data/postgresql.auto.conf"
2023-02-15 07:13:45.825 GMT [28605] LOG: starting PostgreSQL 15.1 on i686-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 32-bit
2023-02-15 07:13:45.825 GMT [28605] LOG: listening on IPv4 address "127.0.0.1", port 5432
2023-02-15 07:13:45.933 GMT [28605] LOG: listening on Unix socket "/home/runtime/pgsql/.s.PGSQL.5432"
2023-02-15 07:13:45.969 GMT [28608] LOG: database system was shut down at 2023-02-15 07:13:35 GMT
2023-02-15 07:13:45.989 GMT [28605] LOG: database system is ready to accept connections
done
server started
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
2023-02-15 07:13:51.480 GMT [28605] LOG: received fast shutdown request
waiting for server to shut down....2023-02-15 07:13:51.512 GMT [28605] LOG: aborting any active transactions
2023-02-15 07:13:51.513 GMT [28605] LOG: background worker "logical replication launcher" (PID 28611) exited with exit code 1
2023-02-15 07:13:51.513 GMT [28606] LOG: shutting down
2023-02-15 07:13:51.536 GMT [28606] LOG: checkpoint starting: shutdown immediate
2023-02-15 07:13:51.908 GMT [28606] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.090 s, sync=0.028 s, total=0.395 s; sync files=2, longest=0.021 s, average=0.014 s; distance=0 kB, estimate=0 kB
2023-02-15 07:13:51.909 GMT [28605] LOG: database system is shut down
done
server stopped
I tried to use postgres-15.0 and postgres-14.4, got the same behavior with both. I am not able to find any open issues w.r.t. shared_preload_libraries extension with new versions of Postgres.
PS: I have built this Postgres from the source code with openssl-1.1.1i.
I am using "citus" library with this.
ALTER SYSTEM SET shared_preload_libraries="citus";
I have generated a new citus.so file from it's source code using postgres-15.1. github.com/citusdata/citus

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

PostgreSQL connection issue after service restart

I have edited my pg_hba file and copied it to server and restarted the services by "sudo service postgresql restart" but after that the server is not connecting.
Showing the below error, Your database returned: "Connection to 138.2xx.1xx.xx:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections."
The Jenkins job and data visualization tools are failing which was working fine previously. What could be the reason.
Getting this in PostgreSQL Log
2019-10-23 07:21:25.829 CEST [11761] LOG: received fast shutdown request
2019-10-23 07:21:25.829 CEST [11761] LOG: aborting any active transactions
2019-10-23 07:21:25.829 CEST [11766] LOG: autovacuum launcher shutting down
2019-10-23 07:21:25.832 CEST [11763] LOG: shutting down
2019-10-23 07:21:25.919 CEST [11761] LOG: database system is shut down
2019-10-23 07:21:27.068 CEST [22633] LOG: database system was shut down at 2019-10-23 07:21:25 CEST
2019-10-23 07:21:27.073 CEST [22633] LOG: MultiXact member wraparound protections are now enabled
2019-10-23 07:21:27.075 CEST [22631] LOG: database system is ready to accept connections
2019-10-23 07:21:27.075 CEST [22637] LOG: autovacuum launcher started
2019-10-23 07:21:27.390 CEST [22639] [unknown]#[unknown] LOG: incomplete startup packet
Below shows no response.
root#Ubuntu-1604-xenial-64-minimal ~ # pg_isready -h localhost -p 5432
localhost:5432 - no response
Below was already added to the postgresql.config file.
listen_addresses = '*'
Do i need to restart the entire server?
Can anyone please help me to resolve this.

postgres: EOF detected for even simple queries

I'm running a postgres server locally on my computer and it seems that even the simple queries like the one below is giving me an EOF detected error.
For instance, this query
ALTER TABLE maintab ADD COLUMN testing numeric;
UPDATE maintab SET testing = numeric1 * numeric2;
And similar activities will throw an EOF error. I'm also running PostGIS with QGIS and my spatial queries, no matter how simple, will throw this error.
I've look around at forums and documentation but nothing can seem to help solve this problem. Is there anything I can do to stop this?
EDIT
I ran a check on my error logs after doing some Googling. Found these logs, not sure what to make of them
2015-09-04 11:18:31 EDT [1138-4] LOG: terminating any other active server processes
2015-09-04 11:18:31 EDT [1208-3] WARNING: terminating connection because of crash of another server process
2015-09-04 11:18:31 EDT [1208-4] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2015-09-04 11:18:31 EDT [1208-5] HINT: In a moment you should be able to reconnect to the database and repeat your command.
2015-09-04 11:18:31 EDT [1138-5] LOG: all server processes terminated; reinitializing
2015-09-04 11:18:31 EDT [3861-1] LOG: database system was interrupted; last known up at 2015-09-04 15:08:49 EDT
2015-09-04 11:18:32 EDT [3861-2] LOG: database system was not properly shut down; automatic recovery in progress
2015-09-04 11:18:32 EDT [3861-3] LOG: record with zero length at 1D/123A250
2015-09-04 11:18:32 EDT [3861-4] LOG: redo is not required
2015-09-04 11:18:32 EDT [3861-5] LOG: MultiXact member wraparound protections are now enabled
2015-09-04 11:18:32 EDT [1138-6] LOG: database system is ready to accept connections
2015-09-04 11:18:32 EDT [3865-1] LOG: autovacuum launcher started
2015-09-04 16:07:22 EDT [1122-1] LOG: database system was interrupted; last known up at 2015-09-04 16:06:25 EDT
2015-09-04 16:07:22 EDT [1179-1] [unknown]#[unknown] LOG: incomplete startup packet
2015-09-04 16:07:23 EDT [1122-2] LOG: database system was not properly shut down; automatic recovery in progress
2015-09-04 16:07:23 EDT [1122-3] LOG: record with zero length at 1D/123A320
2015-09-04 16:07:23 EDT [1122-4] LOG: redo is not required
2015-09-04 16:07:23 EDT [1122-5] LOG: MultiXact member wraparound protections are now enabled
2015-09-04 16:07:23 EDT [1114-1] LOG: database system is ready to accept connections
2015-09-04 16:07:23 EDT [1183-1] LOG: autovacuum launcher started
2015-09-04 12:15:05 EDT [1183-2] LOG: stats collector's time 2015-09-04 16:07:23.363257-04 is later than backend local time 2015-09-04 12:15:05.07308-04
2015-09-04 12:17:34 EDT [1114-2] LOG: server process (PID 3824) was terminated by signal 11: Segmentation fault
2015-09-04 12:17:34 EDT [1114-4] LOG: terminating any other active server processes
2015-09-04 12:17:34 EDT [1183-3] WARNING: terminating connection because of crash of another server process
2015-09-04 12:17:34 EDT [1183-4] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2015-09-04 12:17:34 EDT [1183-5] HINT: In a moment you should be able to reconnect to the database and repeat your command.
2015-09-04 12:17:34 EDT [1114-5] LOG: all server processes terminated; reinitializing
2015-09-04 12:17:34 EDT [3828-1] LOG: database system was interrupted; last known up at 2015-09-04 16:07:23 EDT
2015-09-04 12:17:35 EDT [3828-2] LOG: database system was not properly shut down; automatic recovery in progress
2015-09-04 12:17:35 EDT [3828-3] LOG: redo starts at 1D/123A388
2015-09-04 12:17:35 EDT [3828-4] LOG: unexpected pageaddr 1C/F9258000 in log segment 000000010000001D00000001, offset 2457600
2015-09-04 12:17:35 EDT [3828-5] LOG: redo done at 1D/1255C18
2015-09-04 12:17:36 EDT [3828-6] LOG: MultiXact member wraparound protections are now enabled
2015-09-04 12:17:36 EDT [3833-1] LOG: autovacuum launcher started
2015-09-04 12:17:36 EDT [1114-6] LOG: database system is ready to accept connections

server closed the connection unexpectedly when pg_dump

i am run pg_dump on my vps server, it throw me error:
pg_dump: [archiver (db)] query failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
pg_dump: [archiver (db)] query was: SELECT
( SELECT alias FROM pg_catalog.ts_token_type('22171'::pg_catalog.oid) AS t
WHERE t.tokid = m.maptokentype ) AS tokenname,
m.mapdict::pg_catalog.regdictionary AS dictname
FROM pg_catalog.pg_ts_config_map AS m
WHERE m.mapcfg = '22172'
ORDER BY m.mapcfg, m.maptokentype, m.mapseqno
Then I notice the sql on the above error:
SELECT
( SELECT alias FROM pg_catalog.ts_token_type('22171'::pg_catalog.oid) AS t
WHERE t.tokid = m.maptokentype ) AS tokenname,
m.mapdict::pg_catalog.regdictionary AS dictname
FROM pg_catalog.pg_ts_config_map AS m
WHERE m.mapcfg = '22172'
ORDER BY m.mapcfg, m.maptokentype, m.mapseqno
So I try to run SELECT alias FROM pg_catalog.ts_token_type('22171'::pg_catalog.oid) on psql
So it throw me error:
pzz_development=# SELECT alias FROM pg_catalog.ts_token_type('22171'::pg_catalog.oid);
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> \q
How can I figure out the problem, and dump my data properly?
EDIT:
Then i check postgresql log at /var/log/postgresql/postgresql-9.3-main.log
2015-08-10 16:22:49 CST LOG: server process (PID 4029) was terminated by signal 11: Segmentation fault
2015-08-10 16:22:49 CST DETAIL: Failed process was running: SELECT
( SELECT alias FROM pg_catalog.ts_token_type('22171'::pg_catalog.oid) AS t
WHERE t.tokid = m.maptokentype ) AS tokenname,
m.mapdict::pg_catalog.regdictionary AS dictname
FROM pg_catalog.pg_ts_config_map AS m
WHERE m.mapcfg = '22172'
ORDER BY m.mapcfg, m.maptokentype, m.mapseqno
2015-08-10 16:22:49 CST LOG: terminating any other active server processes
2015-08-10 16:22:49 CST WARNING: terminating connection because of crash of another server process
2015-08-10 16:22:49 CST DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2015-08-10 16:22:49 CST HINT: In a moment you should be able to reconnect to the database and repeat your command.
2015-08-10 16:22:49 CST LOG: all server processes terminated; reinitializing
2015-08-10 16:22:49 CST LOG: database system was interrupted; last known up at 2015-08-10 16:22:45 CST
2015-08-10 16:22:50 CST LOG: database system was not properly shut down; automatic recovery in progress
2015-08-10 16:22:50 CST LOG: unexpected pageaddr 0/2AE6000 in log segment 000000010000000000000004, offset 11427840
2015-08-10 16:22:50 CST LOG: redo is not required
2015-08-10 16:22:50 CST LOG: MultiXact member wraparound protections are now enabled
2015-08-10 16:22:50 CST LOG: autovacuum launcher started
2015-08-10 16:22:50 CST LOG: database system is ready to accept connections