-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Postgres module wait condition is inaccurate #158
Comments
Hi @jrudolph! Thank you for the report! I'm currently working on refactoring log consumers and changing underlying logic for wait strategies. For now, we can consider a workaround, but |
Thanks for the quick response. Can you move the ticket to the correct repo? |
I've opened a feature request for this and transferred the issue to testcontainers-rs-modules-community Thanks one more time! |
It turns out there was no need to introduce In fact, postgres uses different standard streams for the two runs. So we need to expect "the database system is ready to accept connections" once on Closed with #162 |
I think this is an issue in python too |
As already mentioned in testcontainers/testcontainers-rs#533, the postgres module does not sufficiently wait until the container is started up completely. The reason is a peculiarity of the postgres container setup which, with default settings, runs an init script that does a "pre-run" of the database but then restarts the database (as you also can see in the logs of testcontainers/testcontainers-rs#533).
Therefore, the existing wait strategy to wait for the string "database system is ready to accept connections" is not enough because it will trigger during the init script run after which the DB will still restart and be unreachable for a short time.
In testcontainers-java this is accounted for by setting
withTimes(2)
(https://github.com/testcontainers/testcontainers-java/blob/1f38f0d9604edb9e89fd3b3ee1eff6728e2d1e07/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java#L60-L65)Since testcontainers-rs does not seem to support
withTimes
, one workaround is to look for "port 5423" (init script only binds to a unix socket). It would probably better to implementwithTimes
or use a regex that only triggers after the second output of "database system is ready to accept connections".The text was updated successfully, but these errors were encountered: