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

graphqlbackend: check requireed OOB migrations against latest version#48053

Merged
unknwon merged 3 commits into
mainfrom
jc/00-fix-required-oobm
Feb 23, 2023
Merged

graphqlbackend: check requireed OOB migrations against latest version#48053
unknwon merged 3 commits into
mainfrom
jc/00-fix-required-oobm

Conversation

@unknwon

@unknwon unknwon commented Feb 22, 2023

Copy link
Copy Markdown
Contributor

Previously, we were checking agsinst the current running version for required OOB migrations, which is incorrect as pointed out in https://github.com/sourcegraph/sourcegraph/pull/48046#discussion_r1114467855 because if an unfinished OOBM is already deprecated at the current running version the instance won't even start.

Instead, we should be checking against the latest version, (reasonably) taking the assumption that the site admin always wants to upgrade from the current to the latest version (i.e. what's multi-version upgrade is for).

Test plan

Note: The latest version at the time of the screenshot is 4.4.1.

Randomly setting the progress some deprecated OOBM to 0.

CleanShot 2023-02-22 at 23 55 22@2x

@cla-bot cla-bot Bot added the cla-signed label Feb 22, 2023
@unknwon unknwon marked this pull request as ready for review February 22, 2023 16:00
@unknwon unknwon requested review from efritz and eseliger February 22, 2023 16:00
if updateStatus == nil || !updateStatus.HasUpdate() {
return nil, errors.New("no latest update version available (reload in a few seconds)")
}
version, _, ok := oobmigration.NewVersionAndPatchFromString(updateStatus.UpdateVersion)

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.

We want to alert if an unfinished migration is deprecated at or above this value, right? In that case we don't want to use either the current version (previous) or the update version (which is the latest release, if I'm reading correctly), but we want the next version to see if any update will require additional migrations.

I think what we want here is just version.Next() (assuming version is an oobmigration.Version, then we handle the major version transition already).

Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We want to alert if an unfinished migration is deprecated at or above this value, right?

Yes, but without asking the user (which we can), how could we know what version the user intends to upgrade to?

If we only check for the "next" version, how would we solve the following scenario:

  1. The current version is N, and the next version is N+1.
  2. An OOBM is added in N but deprecated at N+2.
  3. N+2 is the latest version that the user intends to upgrade to.

Only checking against N+1 seems would give the wrong conclusion for readiness? 🤔

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.

Good point. Are we only considering migrations which were introduced before the current migration? If not then we might say "this migration that doesn't exist at this release is at 0%".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Are we only considering migrations which were introduced before the current migration?

I feel this is the best we can do, when there are OOBMs that are:

  1. started
  2. not yet done
  3. known to be deprecated using the most conservative algorithm (i.e. checking against the latest version)

indicate definitely not ready, this way we can at least be able to inform and eliminate obvious problems.

WDYT?

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.

Sounds good!

@sourcegraph-bot

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 63f7afb...d27e40a.

Notify File(s)
@efritz internal/database/migration/shared/data/stitched-migration-graph.json

@unknwon unknwon merged commit b715fdf into main Feb 23, 2023
@unknwon unknwon deleted the jc/00-fix-required-oobm branch February 23, 2023 04:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants