feat: Support custom PostgreSQL Docker images#208
Open
jacobsvante wants to merge 2 commits intocornucopia-rs:mainfrom
Open
feat: Support custom PostgreSQL Docker images#208jacobsvante wants to merge 2 commits intocornucopia-rs:mainfrom
jacobsvante wants to merge 2 commits intocornucopia-rs:mainfrom
Conversation
Useful when in need of extra extensions such as PostGIS or TimescaleDB. Also add support for changing port and container name.
The postgres Docker image restarts the database server on first launch. The pg_isready command that is used for the health check returns true before the restart, which I assume is why the 250 ms additional delay exists. When using a custom image which installs extra extensions, this 250 ms delay might not be enough for the container to actually become ready. This is now resolved by replacing the 250 ms delay with a check to ensure that pg_isready responds with OK 5 times in a row.
58f4f87 to
9b645f2
Compare
heksesang
reviewed
May 14, 2024
Comment on lines
+81
to
+87
| let mut consecutive_successes = 0; | ||
| while consecutive_successes < 5 { | ||
| if is_postgres_healthy(opts)? { | ||
| consecutive_successes += 1; | ||
| } else { | ||
| consecutive_successes = 0; | ||
| } |
There was a problem hiding this comment.
Checking the container logs to see if the "PostgreSQL init process complete; ready for start up." line has been printed is probably more robust than relying on an arbitrary amount of successes.
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The main use case is to support PostgreSQL extensions, in my case TimescaleDB.
This PR also includes improvements to the container healthcheck and supports changing port and container name.
This is a breaking change because some public functions have had their signatures changed.