Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.

Use WaitLatch to detect Postmaster death and exit.#6

Open
bizwark wants to merge 3 commits into
mainfrom
pgrag-detect-postmaster-death-with-wait
Open

Use WaitLatch to detect Postmaster death and exit.#6
bizwark wants to merge 3 commits into
mainfrom
pgrag-detect-postmaster-death-with-wait

Conversation

@bizwark

@bizwark bizwark commented Apr 21, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@bizwark bizwark requested a review from hlinnaka April 21, 2025 13:39
Comment on lines +170 to +185
unsafe {
let mask = pg_sys::WL_EXIT_ON_PM_DEATH | pg_sys::WL_LATCH_SET;
let my_latch = &mut (*pg_sys::MyProc).procLatch as *mut pg_sys::Latch;
let events = pg_sys::WaitLatch(
my_latch,
mask as i32,
0,
pg_sys::PG_WAIT_EXTENSION,
);
pg_sys::ResetLatch(my_latch);

if (events & pg_sys::WL_EXIT_ON_PM_DEATH as i32) != 0 {
// postmaster died
pg_sys::proc_exit(1);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use pgrx's wait_latch function for this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants