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:
- The circuit breaker's status changes to
open
. This change is logged. - For 60 seconds, any calls to the failing extension point return an HTTP Status Code
503 (Service Unavailable)
with the fault typeHookCircuitBreakerException
. - After 60 seconds, the circuit breaker's status changes to
half-open
. This change is logged. - The circuit breaker tracks the next 10 calls to the failing extension point. If more than 5 of them fail, return to step 1.
- 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.
- In Business Manager, navigate to Administration > Site Development > Development Setup.
- In the Log Files section, click Log Center.
- Select the Day of Year.
- In the LCQL field, enter
HookCircuitBreaker
. - In the query hits, look for a HookInvocationException entry and click its Stack Trace UUID link.
- 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 24.5 and OCAPI Hooks for Shop API 24.5.