Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command: Update backend hash value only after a successful migration #29860

Merged
merged 2 commits into from
Nov 2, 2021

Conversation

chrisarcand
Copy link
Member

@chrisarcand chrisarcand commented Nov 2, 2021

Replaces #29856
Closes #26259
Closes #26260

The Meta.backend_C_r_S_unchanged() method was sadly pulling too many duties.

It seems to have originally been used as a method to be called when the backend is not changing, with an extra assumption that if the configured backend's hash doesn't match the one in state, surely the hash should just be updated as an option might have been moved to command line flags.

However, this function was used throughout this file as 'the method to load the initialized (but not necessarily configured) backend', regardless of whether or not it is the same (unchanged). This is in addition to Meta.backendFromState(), which is used to load the same thing except in the main codepath of 'init -backend=false'.

These changes separate the concerns of backend_C_r_S_unchanged() by

  1. Fetching the saved backend (savedBackend())
  2. Updating the hash value in the backend cache when appropriate (either by leaving it to the caller to do themselves or by calling updateSavedBackendHash())

This allows migration codepaths to not update the hash value until after a migration has successfully taken place.

Although it would make sense to incoporate Meta.backendFromState() in to this shared API, I've left that alone as it's not consequential to the specific bug we're after here.

Copy link
Contributor

@alisdair alisdair left a comment

Choose a reason for hiding this comment

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

This makes sense to me! And I appreciate the comment changes.

I tested locally against my repro for #26259 too, ✅

…kend

The Meta.backend_C_r_S_unchanged() method was sadly a bit of a mess.

It seems to have originally been used as a method to be called
when the backend is not changing, with an extra assumption that if the
configured backend's hash doesn't match the one in state, surely the
hash should just be updated as an option might have been moved to
command line flags.

However, this function was used throughout this file as 'the method to
load the initialized (but not necessarily configured) backend',
regardless of whether or not it is the same (unchanged). This is in
addition to Meta.backendFromState(), which is used to load the same
thing except in the main codepath of 'init -backend=false'.

These changes separate the concerns of backend_C_r_S_unchanged() by

1) Fetching the saved backend (savedBackend())
2) Updating the hash value in the backend cache when appropriate (either
   by leaving it to the caller to do themselves or by calling
   updateSavedupdateSavedBackendHash())

This allows migration codepaths to *not* update the hash value until
after a migration has successfully taken place.
@chrisarcand chrisarcand force-pushed the fix-init-after-error-take-two branch from 604d45d to 7c0c2e9 Compare November 2, 2021 20:24
@chrisarcand chrisarcand changed the title command: Update backend hash value only after a succesful migration command: Update backend hash value only after a successful migration Nov 2, 2021
@chrisarcand chrisarcand merged commit f04ea2b into main Nov 2, 2021
@chrisarcand chrisarcand deleted the fix-init-after-error-take-two branch November 2, 2021 20:29
@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2021

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backend hash is updated too early
3 participants