Skip to content

#810: Refresh cached quota after reset - #1395

Open
gemshrine wants to merge 2 commits into
zerocracy:masterfrom
gemshrine:810
Open

gemshrine wants to merge 2 commits into
zerocracy:masterfrom
gemshrine:810

Conversation

@gemshrine

Copy link
Copy Markdown
Contributor

Fixes #810

The cached quota count never expires when its reset time passes. The refresh counter advances on ordinary API calls, but a client blocked by the off-quota guard cannot make those calls. Long-running processes can therefore keep treating an already-reset quota as exhausted.

The middleware now records reset times for the core and search resources from quota responses and response headers. An expired timestamp makes the cached quota response stale, so the next quota check fetches fresh counts. remaining reports an expired count as unknown until that refresh. The trace logger checks quota before taking its trace mutex, so a refresh that records a request cannot deadlock while printing the trace.

Regression coverage checks refresh after a core reset without ordinary requests, independent search-resource expiry, reset headers, recovery through off_quota?, and trace printing across an expired quota.

Checks

  • bundle exec ruby -Itest test/fbe/middleware/test_rate_limit.rb
  • bundle exec ruby -Itest test/fbe/test_octo.rb

@gemshrine

Copy link
Copy Markdown
Contributor Author

@yegor256 Could you please take a look at this fix for #810?

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.

Quota response cache does not expire after the reported reset time

1 participant