Don't trigger source refresh for TTL-expired entries when doing search()#250
Don't trigger source refresh for TTL-expired entries when doing search()#250
search()#250Conversation
kriszyp
left a comment
There was a problem hiding this comment.
Hmm, this is clearer, but I think there are of couple cases that don't seem quite right:
- If the entry has expired, and
context.onlyIfCachedisfalseandcheckLoadedistrue, it should load from source, but it is not (it will return the stale/expired entry) - If the entry is invalidated and
context.onlyIfCachedistrue, I think it should return "This entry has expired/invalidated" (the current message is probably a little too terse).
…s for killHarper/logDir/env vars (#235) * Update integration test code * fixup! Update integration test code
…te normal message delivery
|
@Ethan-Arrowood These changes are intended to fix the flakey cached index test. The test performs a get(), search(), and get(), then expects the |
kriszyp
left a comment
There was a problem hiding this comment.
expired data is ok because yeah the data is stale,
The intent of onlyIfCached, is that if it is not set, you can consistently get fresh data across all operations, not fresh data for get and but only fresh data with search with invalidated and fresh data, but not expired data. With the corrected unit test in test/fix-cache-assertions, this branch consistently fails the unit test.
anyway to test this?
Added #265 to track.
|
Whats up with the commits here? This seems to be bringing in a lot of other changes now |
I configured git to rebase instead of merge, so I guess it shows the commits from |
|
okay I guess lets just be sure to squash merge this PR |
Observationally, it appears that the opposite is happening. I see merge commits. |
Bah, I did a |
When
search()iterates over results and encounters a TTL-expired cache entry,transformEntryForSelect()would callensureLoadedFromSource()and await the result before returning the record.The fix separates the three cases that were conflated in a single condition:
onlyIfCached+ expired → return the "expired" indicator (unchanged)INVALIDATEDorEVICTED→ block and reload from source (unchanged)search()→ return stale cached data without touching the source;get()is the correct place to enforce TTL freshnessNote: I have no idea what I'm doing, but this seems to fix the flakey caching tests.