Skip to content

fix: run fini hooks when PgDog exits on SIGTERM - #1586

Open
mehcode wants to merge 1 commit into
pgdogdev:mainfrom
mehcode:rl-sigterm-plugin-shutdown
Open

mehcode wants to merge 1 commit into
pgdogdev:mainfrom
mehcode:rl-sigterm-plugin-shutdown

Conversation

@mehcode

@mehcode mehcode commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #1537

Move SIGTERM handling to a select! in main (inside the block_on) and return from main instead of calling exit(0). Behavior should be the same with the addition of calling plugin shutdowns now.

I edited the integration test and added a fini to make sure it runs on SIGTERM but it breaks the integration test inside of gdb (or at least causes it to think a failure happened), so not sure the best way to add a persistent test for this.


  • Its technically possible to miss a plugin shutdown still if plugins register correctly but build_runtime returns an error. If you think its important to make this a guarantee we could return a RAII guard from plugin::load_from_config.

  • I kept the immediate nature of SIGTERM with runtime.shutdown_background. Technically SIGTERM is supposed to not be immediate (and let all tasks close properly) so that should probably be runtime.shutdown_timeout(..), happy to tweak that if you agree but I left it for now.

@mehcode
mehcode force-pushed the rl-sigterm-plugin-shutdown branch from c024ed0 to 6a6d08c Compare September 18, 2026 01:48
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIGTERM handler calls exit(0) without running plugin fini hooks

1 participant