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

Add fault-tolerance for cache system errors #577

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Commits on Mar 20, 2022

  1. This PR adds several features and changes to error handling:

    - Catch and handle all errors once per request.
    - Remove the `rescuing` blocks from the store proxies; rescuing per-method (read, write, increment) is bad because (a) it may result in undefined behavior, and (b) it will trigger repeated connection timeouts if your cache is down, e.g. N * M * timeout latency where N is the number of Rack::Attack metrics and M is the cache requests per metric.
    - Add `Rack::Attack.ignored_errors` config. This defaults to Dalli::DalliError and Redis::BaseError.
    - Add `Rack::Attack.failure_cooldown` config. This temporarily disables Rack::Attack after an error occurs (including ignored errors), to prevent cache connection latency. The default is 60 seconds.
    - Add `Rack::Attack.error_handler` which takes a Proc for custom error handling. It's probably not needed but there may be esoteric use cases for it. You can also use the shortcut symbols :block, :throttle, and :allow to respond to errors using those.
    - Add `Rack::Attack.calling?` method which uses Thread.current (or RequestStore, if available) to indicate that Rack::Attack code is executing. The reason for this is to add custom error handlers in the Rails Cache, i.e. "raise the error if it occurred while Rack::Attack was executing, so that Rack::Attack and handle it." Refer to readme.
    - Add "Fault Tolerance & Error Handling" section to Readme which includes all of the above.
    johnnyshields committed Mar 20, 2022
    Configuration menu
    Copy the full SHA
    ae9d7fd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d3853e8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    78c0939 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6af71d3 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    59d5619 View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2022

  1. - Use request.env rather than separate env parameter

    - Improvements to readme
    johnnyshields committed Jun 24, 2022
    Configuration menu
    Copy the full SHA
    9cb7822 View commit details
    Browse the repository at this point in the history

Commits on Aug 30, 2022

  1. Configuration menu
    Copy the full SHA
    63a8651 View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2023

  1. Configuration menu
    Copy the full SHA
    958ebe1 View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2023

  1. Configuration menu
    Copy the full SHA
    4ff0da1 View commit details
    Browse the repository at this point in the history

Commits on Nov 16, 2023

  1. Configuration menu
    Copy the full SHA
    2791b9d View commit details
    Browse the repository at this point in the history