fix: ensure cache does not return stale created and ttl values#1469
Merged
Conversation
This PR corrects a severe flaw in the cache design The cache could return old stale records when the record was replaced in the underlying dict since the key is not updated. The following functions where affected: async_entries_with_name async_entries_with_server entries_with_name entries_with_server
CodSpeed Performance ReportMerging #1469 will not alter performanceComparing Summary
|
This comment was marked as outdated.
This comment was marked as outdated.
bdraco
added a commit
to home-assistant/core
that referenced
this pull request
Jan 8, 2025
changelog: python-zeroconf/python-zeroconf@0.137.2...0.138.1 bugfix for a severe flaw in the cache python-zeroconf/python-zeroconf#1469
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cache could return old stale records (incorrect created/ttls -- the contents of the record was correct) when the record was replaced in the underlying dict since the key is not updated (only the value is).
The following functions where affected:
cache.async_entries_with_namecache.async_entries_with_servercache.async_all_by_detailscache.entries_with_namecache.entries_with_servercache.get_all_by_detailscache.get_by_detailscache.get(never used)Technically breaking change:
async_entries_with_nameandasync_entries_with_servernow return alistinstead of adictwhich makesentries_with_nameandentries_with_server. They were likely only used internally