Skip to content

skip import when persisted data exists#360

Open
curtisy1 wants to merge 3 commits intoOverv:masterfrom
curtisy1:master
Open

skip import when persisted data exists#360
curtisy1 wants to merge 3 commits intoOverv:masterfrom
curtisy1:master

Conversation

@curtisy1
Copy link
Copy Markdown

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

curtisy1 and others added 3 commits January 23, 2023 12:47
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.
Comment thread run.sh
fi

if [ "$1" == "import" ]; then
if [ -f /var/lib/postgresql/14/main/.databaseImported ]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

I.E.:
https://github.com/Overv/openstreetmap-tile-server/pull/360/files#diff-d31ce0453051853c17ba2a5225b3d1bfab548e095bab0967d6acfd1b3ce1b35dR130

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or /data/database/postgres/.databaseImported instead, because 14 was already changed to 15 in the master branch.

Comment thread run.sh

service postgresql stop

touch /var/lib/postgresql/14/main/.databaseImported
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we should set this much earlier. That would prevent all these issues with half -imported data.

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.

4 participants