Netflix / Hystrix

Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
24.09k stars 4.7k forks source link

1.5.x HystrixCircuitBreaker.HystrixCircuitBreakerImpl.circuitOpenedOrLastTestedTime #2014

Open zhuhongxu opened 3 years ago

zhuhongxu commented 3 years ago

there has some code in isOpen method, as following: if (circuitOpen.compareAndSet(false, true)) { circuitOpenedOrLastTestedTime.set(System.currentTimeMillis()); return true; } else { return true; } if thread one invokes the circuitOpen.compareAndSet(false, true) yet but not start invoke circuitOpenedOrLastTestedTime.set(System.currentTimeMillis()),and thread two return true at the same time, then thread two will invoke allowSingleTest() and get circuitOpenedOrLastTestedTime but it is 0, because thread one not finish to invoke circuitOpenedOrLastTestedTime.set(System.currentTimeMillis()), so that there will be a very little time during thread one finish to invoke circuitOpenedOrLastTestedTime.set(System.currentTimeMillis()) allowSingleTest() always return true. I think this is a little bug.