OCAPI Hook Circuit Breaker

The Hook Circuit Breaker feature improves stability and saves processing time by protecting the system from high rates of hook failures. It tracks calls to each hook type individually.

Each extension point type has its own circuit breaker instance that tracks the rate of failed executions for that hook. The circuit breaker can be in one of three states: closed, open, or half-open. Normally, it's closed. If at any time, the 100 most recent calls to the hook include more than 50 failures, the following process is triggered:

  1. The circuit breaker's status changes to open. This change is logged.
  2. For 60 seconds, any calls to the failing extension point return an HTTP Status Code 503 (Service Unavailable) with the fault type HookCircuitBreakerException.
  3. After 60 seconds, the circuit breaker's status changes to half-open. This change is logged.
  4. The circuit breaker tracks the next 10 calls to the failing extension point. If more than 5 of them fail, return to step 1.
  5. The circuit breaker's status changes to closed and it resumes tracking calls to the hook. This change is logged.

If your hook calls return 503 (Service Unavailable) errors, use Log Center to investigate the cause.

  1. In Business Manager, navigate to Administration > Site Development > Development Setup.
  2. In the Log Files section, click Log Center.
  3. Select the Day of Year.
  4. In the LCQL field, enter HookCircuitBreaker.
  5. In the query hits, look for a HookInvocationException entry and click its Stack Trace UUID link.
  6. In the stack trace, find the Caused by section. It can contain information about the cause of the hook failures. Some possible causes include:
    • The hook contains a remote call that never returns a response, causing the hook to time out. In this case, try making an asynchronous OCAPI call instead.
    • The hook script contains errors. Fix the code and consider adding error handling measures.

For information on extension points and supported resources, see OCAPI Hooks for Data API 23.1 and OCAPI Hooks for Shop API 23.1.