2ndQuadrant / pglogical

Logical Replication extension for PostgreSQL 17, 16, 15, 14, 13, 12, 11, 10, 9.6, 9.5, 9.4 (Postgres), providing much faster replication than Slony, Bucardo or Londiste, as well as cross-version upgrades.
http://2ndquadrant.com/en/resources/pglogical/
Other
1.02k stars 154 forks source link

Setup signal handler before we unblock signals #385

Closed pavanvd closed 2 years ago

pavanvd commented 2 years ago

The default SIGTERM signal handler implemented by Postgres for background worker processes throws a FATAL error in the handler itself. This is not in sync with rest of the system where we generally process signals out-of-line. This is important because the process might be in a middle of updating shared memory or holding a spinlock and if the process exits without a clean state, may lead to issues.

One of our customers reported a "Stuck spinlock" PANIC, which was tracked down to this. While it might be a good idea to fix the default signal handler in Postgres, for now, work it around by setting up our handler before we unblock the signals. This is how other processes work and is the right thing to do.