skip import when persisted data exists#360
Open
curtisy1 wants to merge 3 commits intoOverv:masterfrom
Open
Conversation
When running in a kubernetes cluster, the import step should usually only happen once. For example, this could be done using an init container. Doing so and changing the deployment in a way that triggers a re-deploy currently fails because the database has already been initialized and persisted. To avoid this, write an empty file to the postgresql directory and check whether it exists on the next successful run to avoid running the setup again.
hummeltech
reviewed
Mar 19, 2023
| fi | ||
|
|
||
| if [ "$1" == "import" ]; then | ||
| if [ -f /var/lib/postgresql/14/main/.databaseImported ]; then |
There was a problem hiding this comment.
Good idea, how about just using the already existing "complete" file?
Suggested change
| if [ -f /var/lib/postgresql/14/main/.databaseImported ]; then | |
| if [ -f /data/database/planet-import-complete ]; then |
Contributor
There was a problem hiding this comment.
Or /data/database/postgres/.databaseImported instead, because 14 was already changed to 15 in the master branch.
nielsole
reviewed
Mar 19, 2023
|
|
||
| service postgresql stop | ||
|
|
||
| touch /var/lib/postgresql/14/main/.databaseImported |
Collaborator
There was a problem hiding this comment.
I wonder whether we should set this much earlier. That would prevent all these issues with half -imported data.
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.
When running in a kubernetes cluster, the import step should usually only happen once.
For example, this could be done using an init container.
Doing so and changing the deployment in a way that triggers a re-deploy currently fails
because the database has already been initialized and persisted.
To avoid this, write an empty file to the postgresql directory and check whether it exists
on the next successful run to avoid running the setup again.
I don't see any downsides to this except wanting to import another region than what already exists. But that would currently fail as well, I believe