Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

migrations: dirty flag can linger even after a successful migration #25089

Closed
@chrismwendt

Description

@chrismwendt

It's possible for a migration to complete successfully but leave the dirty flag set to true.

This requires unnecessary manual intervention to fix, and the fix is always UPDATE schema_migrations SET dirty = 'f'.

Here's how it can happen:

  • The frontend starts up and begins a golang-migrate migration
  • golang-migrate sets the dirty flag to true
  • golang-migrate sends the SQL commands to Postgres
  • The migration happens to be slow, and the frontend pod gets restarted by Kubernetes after 5 minutes
  • The SQL commands complete successfully
  • The dirty flag is left set to true (if the SQL commands completed fast enough, the frontend would still be around and golang-migrate would set the dirty flag to false)
  • The frontend pod starts back up and sees a dirty database and prints the dreaded "Failed to migrate the DB. Please contact support@sourcegraph.com for further assistance: Dirty database version 1528395882. Fix and force version."

Solutions

Previous work

We intended to fix this in the past, but I accidentally merged the PR into the wrong branch and it never got into master 🤦‍♂️ https://github.com/sourcegraph/sourcegraph/pull/7909

Metadata

Metadata

Assignees

Labels

team/graphGraph Team (previously Code Intel/Language Tools/Language Platform)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions