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

Stop serving stale responses from negative cache. #3736

Closed
wants to merge 1 commit into from

Conversation

gonzalop
Copy link
Contributor

@gonzalop gonzalop commented Mar 8, 2020

Serving stale responses from the negative cache interacts poorly with
other plugins and seems to confuse users.

Fixes #3586.

1. Why is this pull request needed and what does it do?

See issue #3586

2. Which issues (if any) are related?

#3586

3. Which documentation changes (if any) need to be made?

None.

4. Does this introduce a backward incompatible change or deprecation?

No.

Serving stale responses from the negative cache interacts poorly with
other plugins and seems to confuse users.

Fixes coredns#3586.

Signed-off-by: Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>
@codecov-io
Copy link

Codecov Report

Merging #3736 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3736      +/-   ##
=========================================
+ Coverage   56.77%   56.8%   +0.02%     
=========================================
  Files         220     220              
  Lines       11071   11071              
=========================================
+ Hits         6286    6289       +3     
+ Misses       4303    4300       -3     
  Partials      482     482
Impacted Files Coverage Δ
plugin/cache/handler.go 92.95% <100%> (+7.04%) ⬆️
plugin/errors/errors.go 95.23% <0%> (-4.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a64f0c7...1fa10a7. Read the comment docs.

@chrisohaver
Copy link
Member

Should getIgnoreTTL check the positive cache for an unexpired entry before returning a stale negative cache entry?

@gonzalop
Copy link
Contributor Author

It is the same logic present in get, but if you prefer it that way, I'll flip the order.

@chrisohaver
Copy link
Member

chrisohaver commented Mar 10, 2020

It is the same logic present in get, but if you prefer it that way, I'll flip the order.

No, not exactly. I'm not suggesting to simply flip the order (I agree, that would be pointless).

I'm suggesting ...

  1. if a fresh neg-cache entry exists return it.
  2. if a stale neg-cache entry exists check pos-cache for fresh entry:
    • if a fresh pos-cache entry exists, return pos-cache entry
    • if no fresh pos-cache entry exists, return the stale neg-cache entry
  3. if the neg-cache entry is rotten, or does not exist, check pos-cache entry.
  4. if pos-cache entry exists and is not rotten, return it

This would prevent a stale neg-cache entry from masking a fresh pos-cache entry (e.g. put in place by the stale retrieve prefetch).

fresh/stale/rotten definitions:
fresh = unexpired cache entry
stale = expired cache entry within stale threshold
rotten = expired cache entry past stale threshold

@chrisohaver
Copy link
Member

See #3744 for alternate fix.

@gonzalop
Copy link
Contributor Author

Closing in favor of chris' fix.
Thanks!

@gonzalop gonzalop closed this Mar 13, 2020
@gonzalop gonzalop deleted the serve_stale branch July 1, 2023 13:25
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.

"serve_stale" option in the "cache" plugin behaves incorrectly
3 participants