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

bugfix: KVStore (analyzer cache): Fix retrieval and error handling #409

Merged
merged 6 commits into from May 9, 2023

Conversation

Andrew7234
Copy link
Collaborator

@Andrew7234 Andrew7234 commented May 5, 2023

[Mitja] This PR cleans up KVStore and fixes a bug in the process:

  • Abstracts away fetching of a known-type value into a separate helper func
  • Abstracts away the KVStore interface
  • Adds unit tests (that fail the old code)
  • Fixes a bug in GetFromCacheOrCall where if a value was in the cache, we used to not use it
  • Fixes a bug in GetFromCacheOrCall where if a value was in the cache but couldn't be retrieved correctly (e.g. because of the wrong type), we logged too many errors

@Andrew7234 Andrew7234 changed the title cached-based analyzer: use cached value bugfix: cached-based analyzer: use cached value May 5, 2023
@mitjat mitjat force-pushed the andrew7234/cache-fix branch 2 times, most recently from f8d29c7 to 729d71c Compare May 5, 2023 19:21
Copy link
Collaborator

@pro-wh pro-wh left a comment

Choose a reason for hiding this comment

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

what does this do?

if err2 != nil {
cache.logger.Warn(fmt.Sprintf("failed to unmarshal key %s from cache into %T: %v", key.Pretty(), result, err2))
}
var result *Value
Copy link
Collaborator

Choose a reason for hiding this comment

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

you have it unmarshal into a nil pointer? 🤨

Copy link
Collaborator

Choose a reason for hiding this comment

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

It was supposed to be a quick blind&untested fix, more like a suggestion to the existing PR. Instead, my commits became its own thing now. Thanks, fixed, and added unit tests.

@mitjat mitjat changed the title bugfix: cached-based analyzer: use cached value bugfix: KVStore (analyzer cache): Fix error handling May 8, 2023
@mitjat mitjat changed the title bugfix: KVStore (analyzer cache): Fix error handling bugfix: KVStore (analyzer cache): Fix retrieval and error handling May 8, 2023
@mitjat mitjat requested a review from pro-wh May 8, 2023 23:02
Co-authored-by: Peter Us <peter@u-s.si>
Copy link
Collaborator

@mitjat mitjat left a comment

Choose a reason for hiding this comment

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

selfhighfive.gif 🙄

I have to formally approve since ptrus is not in CODEOWNERS.

@mitjat mitjat merged commit 4d3a6ad into main May 9, 2023
5 checks passed
@mitjat mitjat deleted the andrew7234/cache-fix branch May 9, 2023 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants