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

feat(cache): Repository cache fingerprinting #17367

Merged
merged 24 commits into from
Aug 30, 2022

Conversation

zharinov
Copy link
Collaborator

@zharinov zharinov commented Aug 23, 2022

Changes

  • New cache repo revision
  • New fingerprint parameter
  • Gradual migration

Context

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@zharinov zharinov marked this pull request as draft August 23, 2022 17:58
@zharinov
Copy link
Collaborator Author

Blocked by #17364

@zharinov zharinov marked this pull request as ready for review August 23, 2022 18:30
Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

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

Why the need for gradual migration instead of full? Assumption that it's too heavy for the app in production?

@zharinov
Copy link
Collaborator Author

Why the need for gradual migration instead of full? Assumption that it's too heavy for the app in production?

Yes, otherwise it will reset all the caches instantly 🤷‍♂️

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

🤔 is writing new json files so bad? i don't see a big issue for the hoseted app. I think it's always copying the cache file after each repo anyways. 🤔

@zharinov zharinov marked this pull request as draft August 23, 2022 19:00
@zharinov
Copy link
Collaborator Author

zharinov commented Aug 23, 2022

It's not about writing JSON, we have to reset all the cache while migrating from 12 to 13. I forgot to add this "resetting" part.

@viceice
Copy link
Member

viceice commented Aug 23, 2022

It's not about writing JSON, we have to reset all the cache while migrating from 12 to 13. I forget to add this "resetting" part.

but didn't we still use / migrate the old cache? so it's irrelevant if we change it afterwards?
or do you fully discard the old cache?

@zharinov
Copy link
Collaborator Author

If we migrate gradually, we have to migrate previous versions to 12, or reset the data and migrate it to 13 for the smaller fraction of repos. If we're okay to reset them all at once, I think we can make "fresh start" for the revisions.

@viceice
Copy link
Member

viceice commented Aug 23, 2022

i still don't know why we can't migrate all old caches like we did before?

btw the hosted app is using multiple worker nodes and every node will only process one repo at a time.

lib/util/cache/repository/index.spec.ts Outdated Show resolved Hide resolved
lib/util/cache/repository/init.ts Outdated Show resolved Hide resolved
@zharinov zharinov marked this pull request as ready for review August 24, 2022 09:44
# Conflicts:
#	lib/util/cache/repository/impl/cache-factory.ts
#	lib/util/cache/repository/impl/local.spec.ts
Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

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

Hard to tell from code inspection alone

viceice
viceice previously approved these changes Aug 29, 2022
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

i still don't understand why we can't migrate old cache this time

@zharinov
Copy link
Collaborator Author

zharinov commented Aug 29, 2022

Because for some repos, we may reuse the cache of previously deleted repository with same name, and there is no easy way to detect repos like these.

@viceice
Copy link
Member

viceice commented Aug 29, 2022

Because for some repos, we may reuse the cache of previously deleted repository with same name, and there is no easy way to detect repos like these.

that case is very rare, so those could be manually clean like today?

@rarkins
Copy link
Collaborator

rarkins commented Aug 29, 2022

How much work would it be to preserve existing caches? i.e. knowing that maybe some of them are invalid, but thinking it's an OK trade-off?

@zharinov
Copy link
Collaborator Author

Well, we may just write and check fingerprints only for repos that don't have any cache (i.e. only for new ones).

@rarkins
Copy link
Collaborator

rarkins commented Aug 29, 2022

So the choice is between:

  • (current) burn the existing cache, but do it gradually to prevent overload, or
  • preserve the existing cache, do it immediately: add the fingerprint to all existing caches?

@zharinov
Copy link
Collaborator Author

Not exactly:

  • (current) reset all the cache at once and start with newest revision
  • (previous) gradually migrate all the caches controlling pace of change via hardcoded variable
  • add fingerprint to caches, despite some of them can be wrong

@viceice
Copy link
Member

viceice commented Aug 29, 2022

i would simply add the fingerprint if missing as the wrong cases are only a few repos.

Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

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

OK, let's go with @viceice's suggestion and I'll keep manually fixing any we find in the app. Sorry for the changing of requirements

@zharinov
Copy link
Collaborator Author

No problem, I'll restore it

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

otherwise LGTM

lib/util/cache/repository/impl/base.ts Show resolved Hide resolved
@rarkins rarkins enabled auto-merge (squash) August 30, 2022 04:47
@rarkins rarkins merged commit 6a93997 into renovatebot:main Aug 30, 2022
@rarkins rarkins deleted the feat/repo-cache-fingerprints branch August 30, 2022 04:58
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 32.184.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2022
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.

Unrecoverable repo cache problem when repository reset
4 participants