{"record":{"id":"fda01248cb834731","repo":"App-vNext/Polly","slug":"the-circuit-is-manually-held-open-and-is-not-allow","errorCode":null,"errorMessage":"The circuit is manually held open and is not allowing calls.","messagePattern":"The circuit is manually held open and is not allowing calls\\.","errorType":"exception","errorClass":"IsolatedCircuitException","httpStatus":null,"severity":"error","filePath":"src/Polly/CircuitBreaker/CircuitStateController.cs","lineNumber":161,"sourceCode":"    }\n\n    public void OnActionPreExecute()\n    {\n        switch (CircuitState)\n        {\n            case CircuitState.Closed:\n                break;\n            case CircuitState.HalfOpen:\n                if (!PermitHalfOpenCircuitTest())\n                {\n                    throw GetBreakingException();\n                }\n\n                break;\n            case CircuitState.Open:\n                throw GetBreakingException();\n            case CircuitState.Isolated:\n                throw new IsolatedCircuitException(\"The circuit is manually held open and is not allowing calls.\");\n            default:\n                throw new InvalidOperationException(\"Unhandled CircuitState.\");\n        }\n    }\n\n    public abstract void OnActionSuccess(Context context);\n\n    public abstract void OnActionFailure(DelegateResult<TResult> outcome, Context context);\n\n    public abstract void OnCircuitReset(Context context);\n}\n\n","sourceCodeStart":143,"sourceCodeEnd":174,"githubUrl":"https://github.com/App-vNext/Polly/blob/d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac/src/Polly/CircuitBreaker/CircuitStateController.cs#L143-L174","documentation":"Thrown at execution time (not construction) when a CircuitBreaker is in the Isolated state and a delegate is run through it. Isolation is a manual hold: an operator or code calls circuitController.Isolate() (AdvancedCircuitBreaker manual control) to force the circuit Open and block all traffic for maintenance or incident response. Until Reset() is called, every execution throws IsolatedCircuitException.","triggerScenarios":"Calling an action through a breaker whose controller has been put into Isolated mode via the manual isolate API, then executing any delegate before calling Reset. This is runtime behavior of CircuitStateController when CurrentState == CircuitState.Isolated.","commonSituations":"A maintenance job or admin endpoint isolates a downstream-dependency breaker and the application keeps serving requests; tests that isolate a breaker and forget to reset it leak the state into subsequent test cases; a graceful-shutdown hook isolates a breaker but liveness probes still route traffic.","solutions":["Call Reset() on the breaker's controller to leave Isolation before executing again.","If isolation was set by an operator, coordinate the maintenance window so traffic is drained (and probes/health checks account for it) before Reset.","In tests, dispose or reset the shared breaker instance in a finally/cleanup to avoid state leakage between cases."],"exampleFix":"// before\nbreakerControl.Isolate();\nvar result = await policy.ExecuteAsync(ct => client.GetAsync(url, ct), cancellationToken);\n\n// after\n// drain traffic / finish maintenance, then:\nbreakerControl.Reset();\nvar result = await policy.ExecuteAsync(ct => client.GetAsync(url, ct), cancellationToken);","handlingStrategy":"try-catch","validationCode":"// before executing, check the controller state if you hold it\nif (breakerControl.CircuitState == CircuitState.Isolated)\n{\n    return Result.Unavailable(\"Downstream manually isolated\");\n}\nreturn await policy.ExecuteAsync(action, ct);","typeGuard":"bool IsSafeToCall(CircuitState s) => s != CircuitState.Isolated && s != CircuitState.Open;","tryCatchPattern":"try { return await policy.ExecuteAsync(action, ct); }\ncatch (IsolatedCircuitException ex) { log.MaintenanceBlock(ex); return Result.Unavailable(ex.Message); }","preventionTips":["Drain traffic before calling Isolate(); call Reset() before resuming.","Expose isolation state through health checks so load balancers stop sending traffic.","In tests, always Reset() or recreate the breaker in test cleanup."],"tags":["circuit-breaker","isolation","runtime-state","maintenance","csharp"],"backgroundTag":null,"analyzedSha":"d0e46bdb1ee11ea50d0e4b6846d2633d6bc09bac","analyzedAt":"2026-08-13T16:36:01.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}