Skip to content

Conversation

@jeltz
Copy link
Contributor

@jeltz jeltz commented Jan 14, 2026

The pg_ctl start -w command already waits for PostgreSQL to be ready to accept connections before returning so waiting two more seconds does not help. Instead it wastes a total of 6 seconds for a whole run of the test suite.

The documentation for -w explains it very well:

       -w
       --wait
           Wait for the operation to complete. This is supported for the modes start, stop, restart,
           promote, and register, and is the default for those modes.

           When waiting, pg_ctl repeatedly checks the server's PID file, sleeping for a short amount of
           time between checks. Startup is considered complete when the PID file indicates that the
           server is ready to accept connections. Shutdown is considered complete when the server
           removes the PID file.  pg_ctl returns an exit code based on the success of the startup or
           shutdown.

           If the operation does not complete within the timeout (see option -t), then pg_ctl exits
           with a nonzero exit status. But note that the operation might continue in the background and
           eventually succeed.

Question for the maintainers: I may want to contribute some more clean up for the test suite, but if so do you prefer many small PRs or larger ones with several cleanup commits in the same PR?

The pg_ctl start -w command already waits for PostgreSQL to be ready to
accept connections before returning so waiting two more seconds does not
help. Instead it wastes a total of 6 seconds for a whole run of the test
suite.
@larskanis
Copy link
Collaborator

The sleep 2 was introduced 16 years ago in commit d858674 . Maybe to that time -w didn't work on all platforms.

You can put the commits into one PR since they often tend to be dependent on each other. I can cherry-pick when in doubt.

@larskanis larskanis merged commit ca0476b into ged:master Jan 14, 2026
35 of 36 checks passed
@jeltz
Copy link
Contributor Author

jeltz commented Jan 14, 2026

Thanks for the quick response!

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.

2 participants