-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
[Bug]: PostgreSQL container fails part of the times #1619
Comments
Hey @doron-cohen I noticed you are overriding the default wait strategy that comes with the postgres module. Is there a reason for that? The default one is needed because postgres needs two occurrences of that log entry. I say override because of Line 92 in d6d5b0b
This probably is a bug though 🤔 |
Hey @mdelapenya I didn't see any existing wait strategies. I am looking here: https://github.com/testcontainers/testcontainers-go/blob/v0.22.0/modules/postgres/postgres.go#L113. Am I looking at the wrong place? I also looked at the latest 0.23 version and didn't find any. |
BTW, I added the SQL wait strategy since I found the PG container not to be completely ready after |
You are right 🤔 I thought it was in the default settings for the module (I was typing from phone at that moment, I'm now back at my desktop), and it's defined in the tests: https://github.com/testcontainers/testcontainers-go/blob/v0.23.0/modules/postgres/postgres_test.go#L35 I think we should probably do of the following things: |
Thanks. This will clear up the confusion around waiting for it to be ready. Now the only thing remaining is failure to start from time to time. Do you need any logs or information to try and debug it? |
Yes please, the library should fail if any of the preStart hooks fails, and the wait strategies happens there. And the container logs should be outputted to the terminal, so you should see if there is anything in there |
I added most of it in the issue. The container logs and all. I couldn't find anything unusual but let me try and compare to the logs on a successful startup. Anyway, this line is suspicious:
I raise the |
By the Docker endpoint, it seems that inspecting the container caused the deadline exceeded error. Could it be that the ctx context has a timeout or something that causes it to be cancelled before expected? |
I think this is related to postgres container behavior which
Testcontainers for Java uses the following log strategy to happen so mark the container as a ready to receive connections. Another issue could be related to the log strategy provided by Testcontainers for Java, which would fail when postgres image (custom images) contains data already because in that case the number of occurrences for the regex is just 1. See logs attached in the issue description. Just for awareness, probably not a priority to fix it right away. |
@doron-cohen I think #2208 could be related, as it improves the examples with an wait.ForSQL condition. In any case, the example provided here https://golang.testcontainers.org/modules/postgres/ is showing how to configure Postgres in a generic use case, so I'd say that we can close this issue. Please let me know if it's fine to close it. Thanks! |
Closing as the example is illustrative enough. Please feel free to reopen it if you consider it. Thanks in advance! |
Testcontainers version
0.22.0
Using the latest Testcontainers version?
No
Host OS
Mac
Host arch
ARM
Go version
1.20
Docker version
Docker info
What happened?
Some of the times the PostgreSQL container fails with the following logs / message. This is how I use the module:
Relevant log output
Additional information
No response
The text was updated successfully, but these errors were encountered: