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

Donot override cache atime when scanning from local disk #5692

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

polyrabbit
Copy link
Contributor

Scanning from disk overwrites size and atime of existing cache items in memory:

  1. size is overwritten by the physical size of the file, which includes the logical size plus the CRC footer. However, when adding cache in other places, we use the logical size. I suppose it's better to be consistent on which size to use.

  2. The granularity of file system's atime is relatively coarse (relatime), and some even have atime disabled (noatime). However, atime recorded in memory has finer granularity and is more accurate in most cases. Overwriting atime in memory blindly would cause the expire eviction strategy not working as expected.

cache.keys[k] = cacheItem{it.size, uint32(time.Now().Unix())}
} else {
cache.keys[k] = cacheItem{int32(size), uint32(time.Now().Unix())}
Copy link
Contributor

Choose a reason for hiding this comment

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

cache file maybe removed in cleanupExpire after open

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.

2 participants