Bird
0
0

Identify the bug in this circuit breaker pseudocode:

medium📝 Analysis Q6 of 15
Microservices - Resilience Patterns
Identify the bug in this circuit breaker pseudocode:
if breaker.state == 'OPEN':
  call_service()
else:
  try:
    call_service()
  except:
    breaker.state = 'OPEN'
AIt does not handle CLOSED state properly
BIt never changes state to HALF-OPEN
CIt does not reset failure count on success
DIt calls service when state is OPEN, should fail fast
Step-by-Step Solution
Solution:
  1. Step 1: Analyze behavior when state is OPEN

    The code calls the service even when breaker is OPEN, which defeats fail fast purpose.
  2. Step 2: Identify correct OPEN state action

    In OPEN state, calls should be blocked or failed immediately, not forwarded.
  3. Final Answer:

    It calls service when state is OPEN, should fail fast -> Option D
  4. Quick Check:

    OPEN state must fail fast, not call service [OK]
Quick Trick: OPEN state must not call service, fail fast instead [OK]
Common Mistakes:
MISTAKES
  • Allowing calls in OPEN state
  • Ignoring failure count reset
  • Missing HALF-OPEN state handling

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes