postgresqlfatal-errorerror-logging

How to trigger PANIC in PostgreSQL 10


I'm using PostgreSQL 10 server version locally for educational purposes, and one of my tasks is to force a PANIC Error on this version just to test how is reported in the log files.

I've edited the /etc/postgresql/10/main/postgresql.conf and modified the following lines:

log_min_messages = PANIC
log_min_error_statement = PANIC

Following PostgreSQL's lastest documentation it specifies that:

PANIC Reports an error that caused all database sessions to abort.

I wanted to know if there was an easy way to trigger this kind of error and get it to be printed on the log files.

I searched a bit, but didn't find anything that could work easily.


Solution

  • Setting those two parameters to PANIC is not a good idea. Leave them at ERROR or WARNING, PANIC messages will be logged anyway.

    There are many ways to provoke a panic. You could for example remove write permissions on the pg_wal directory or other important data structures. Then create some data modification activity (or call pg_switch_wal a couple of times).