0

Is it safe to kill and restart a running Flyway migration, or does this risk leaving the database in an inconsistent state?

We would like to run Flyway via a Kubernetes Job managed by a Helm chart that deletes and re-creates jobs under certain conditions. When a job is deleted, its pod is terminated (even if it's running), resulting in the Flyway process being terminated with SIGTERM. The new job will then create a new pod and start the Flyway process anew.

Is this safe for Flyway and for the databases it manages? Or do we need to find a different way to manage jobs?

We're currently using PostgreSQL and Cloud Spanner.

scjody
  • 959
  • 2
  • 7
  • 12
  • See https://flywaydb.org/documentation/configuration/parameters/lockRetryCount. Also, consider making your script idempotent (note there's some argue about it). – ShaharT Sep 15 '22 at 22:50
  • Unfortunately that doesn't answer my question. Flyway does claim to lock between multiple instances executing in parallel, but my question is if a given instance can safely be killed via SIGTERM. This is a concern whether we have one instance or several executing in parallel. – scjody Sep 21 '22 at 17:33

0 Answers0