Fix RO sync: clear LRU for all log updates#399
Conversation
|
Clearing all entries is probably safer indeed. Another approach might be to have a generation counter on each entry, and then compare the generation counter of the file with the generation counter of the cached entry, and consider the entry stale if it is older. |
|
Hmm I'm slightly worried of the performance impact of double-checking the LRU freshness on every query, it felt more predictable to only penalize the read-only instance for calling That being said, I believe it should be possible for |
You are right, keeping a RO client efficiently in-sync with another one is not really possible currently, and the generation counter wouldn't really help (you need to discard all LRU entries, whenever anything changes in the index, even if we have per-entry generation counters, we'd still need to read that counter to know whether it changed or not).
Yes, that sounds like a better approach than what I was suggesting with the generation counters. Followup PR sounds good, currently I'm just evaluating whether I can use 'index' in a project, I'm not using it yet as such. |
As reported by @edwintorok in #398, a read-only instance would sometimes fail to find the latest value after doing a
sync, because it would keep finding the old value in its LRU cache (and ignore the more recent writes).The quick-fix is to always clear the LRU whenever
syncdiscovers that the log has changed on disk... It's not super satisfying as we could be more fine grained and update the LRU with the new bindings from the log, but it's the strategy the code was already using for some (but not all) log updates.