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

Flaws in handling of HALF_OPEN state leading to ineffectual circuit-breaker under persistent failure conditions #119

Closed
jerryjvl opened this issue Dec 12, 2017 · 2 comments
Assignees
Labels

Comments

@jerryjvl
Copy link
Contributor

When _startTimer puts STATE into HALF_OPEN, this means that the circuit no longer registers as opened.

This means in fire when it checks if (this.opened && !this.pendingClose), it doesn't just let the single next request through, but it opens the flood-gates to all new requests passing through un-rejected.

Suggestion is to fix change this to if (!this.closed && !this.pendingClose).

When this is fixed , a new problem will surface, which is that if _startTimer fires, lets a single request through, and that request fails, it is quite likely that the failure rate has dropped below the threshold meaning that fail() will not re-issue a circuit.open() and so the timer will never trigger again meaning that all requests remain perpetually rejected.

I'd suggest that for this problem, amending the error-rate conditional in fail() from:
if (errorRate > ... || circuit.options.maxFailures >= stats.failures) {
to:
if (errorRate > ... || ... >= stats.failures || circuit.halfOpen) {
So that any failure in a half-open state causes the circuit to re-open and eventually make another attempt at closing.

@lance
Copy link
Member

lance commented Dec 13, 2017

Connects to: #120

@lance
Copy link
Member

lance commented Dec 13, 2017

Fix landed in: 04df6f7

@lance lance closed this as completed Dec 13, 2017
@ghost ghost removed the needs-review label Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants