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

Include repo etags in transactions #3860

Merged
merged 1 commit into from Jul 21, 2023

Conversation

HebaruSan
Copy link
Member

Problem

In the course of investigating why available modules were missing in #3699, users shared their registries, which revealed that the server etags (see #2682) were getting out of sync with the available modules; users were ending up with old module lists but up-to-date etags. This meant that if they tried to Refresh immediately, it would say the list was already up to date, even though it wasn't.

Cause

I found this very confusing for quite a long while. That data is all part of the Registry object; shouldn't it all be saved to registry.json together or not at all? No! There is one specific scenario in which they can get out of sync:

  1. Metadata retrieved from network successfully
  2. Etags updated
  3. Module list updated
  4. Exception thrown while still inside transaction (any exception would cause this, but in practice it was ReinstallModuleKraken from Replace repo-reinst with kraken, handle in UIs #3344)
  5. Transaction handling reverts to the most recently saved copy of the registry, which happened at the start of step 3, after the etags were updated but before the modules were updated

Changes

In #3828 we eliminated this exception, so this is already functionally fixed, but architecturally it's still important to make the data objects behave properly.

Now the etags are saved by a new Registry.SetETags function, which calls EnlistWithTransaction first, which will save off a copy of the registry with the original etags. This will ensure that if the registry is reverted in a transaction, the etags will accurately reflect the state of the available modules list.

@HebaruSan HebaruSan added Bug Easy This is easy to fix Core (ckan.dll) Issues affecting the core part of CKAN Registry Issues affecting the registry labels Jul 20, 2023
@HebaruSan HebaruSan requested a review from techman83 July 20, 2023 22:52
Copy link
Member

@techman83 techman83 left a comment

Choose a reason for hiding this comment

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

That's quite an edge case, good find! LGTM

@HebaruSan HebaruSan merged commit 4734804 into KSP-CKAN:master Jul 21, 2023
10 checks passed
@HebaruSan HebaruSan deleted the fix/etag-rollback branch July 21, 2023 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Core (ckan.dll) Issues affecting the core part of CKAN Easy This is easy to fix Registry Issues affecting the registry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants