-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#24396] YSQL: Harden Postgres shutdown and restart behavior
Summary: The yb-tserver starts Postgres process and monitors it. If Postgres crashes then the yb-tserver restarts it. Postgres writes two lock files `postmaster.pid`,and `<socket>.lock` with its `pid` information. On a Postgres restart it checks to see if these files exist and if the processes indicated by them are still running and fails its startup to avoid running concurrent instances of Postgres. In linux `pid` (process id) and `tid` (thread id) share the same numbering space, so if a tserver thread picks up the number then it causes Postgres to enter a incorrect crash loop. This change includes the following changes to yb-tserver that ensure we cleanly handle hung Postgres process, and stale lock files: - Handle both the `postmaster.pid` and `<socket>.lock` files. - Only kill the pid if it is a Postgres process. - Detect stuck postgres processes in mac using `proc_pidinfo`. - Kill hung Postgres and cleanup lock files before each Postgres startup instead of doing it only once at tserver startup. - Use `SIGQUIT` as `YB_PG_PDEATHSIG` instead of `SIGINT`. This causes Postmaster to enter "Immediate Shutdown" where it kills other backend with `SIGQUIT` reducing the chances of a hung Postgres. Also setting `report_thread_leaks=0` for TSAN to suppress thread leak errors. Postgres invokes `_exit` which will terminate the entire group, and not leak any threads. - Use `quickdie` in pg_cron background worker to keep it inline with the pg_cron launcher worker. Jira: DB-13307 Test Plan: PgWrapperOneNodeClusterTest, TestPostgresLockFiles Reviewers: slingam, kramanathan, smishra, telgersma Reviewed By: kramanathan, telgersma Subscribers: yql, ybase Differential Revision: https://phorge.dev.yugabyte.com/D39207
- Loading branch information
Showing
6 changed files
with
185 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.