Skip to content

Return True when there are no user backends during shutdown - #3724

Open
zhiqiangwang08 wants to merge 4 commits into
patroni:masterfrom
zhiqiangwang08:master
Open

zhiqiangwang08 wants to merge 4 commits into
patroni:masterfrom
zhiqiangwang08:master

Conversation

@zhiqiangwang08

Copy link
Copy Markdown

When PostgreSQL has no user backends, wait_for_user_backends_to_close() implicitly returns None, so _do_stop() skips the early on_safepoint callback. The watchdog can remain armed while PostgreSQL completes its remaining shutdown work.

Return True explicitly for the empty-backend case, as documented. Keep the existing behavior for active backends, timeouts, and failures to retrieve child processes unchanged.

Add regression coverage for empty child lists and auxiliary-only/disappeared children, with and without a timeout. Also verify that the safepoint callback runs before waiting for the postmaster to exit, and clarify this behavior in the watchdog documentation.

Fixes #3723.

Validation on Windows / Python 3.12:

  • Full unit suite and doctests (pytest tests --doctest-modules patroni): 754 passed, 17 skipped, 39 subtests passed.
  • Full flake8 check (flake8 patroni tests setup.py): passed.
  • git diff --check: passed.
  • Before the fix, the new regression coverage failed in all six empty-backend subcases.

Linux watchdog and PostgreSQL/DCS integration scenarios have not been run locally.

@zhiqiangwang08 zhiqiangwang08 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fix issue #3723

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.

wait_for_user_backends_to_close() returns None when there are no user backends, so on_safepoint() is skipped and the watchdog stays armed

1 participant