[jboss-jira] [JBoss JIRA] (WFWIP-307) MP Fault Tolerance - unexpected behaviour @Fallback method calls with @CircuitBreaker

Miroslav Novak (Jira) issues at jboss.org
Wed Feb 26 11:06:45 EST 2020


     [ https://issues.redhat.com/browse/WFWIP-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Miroslav Novak updated WFWIP-307:
---------------------------------
    Description: 
MP FT does not behave correctly in case when there is @CircuitBreaker, @Fallback, @Retry and @Asynchronous on service method. @CircuitBreaker does not get opened based on its configuration and @Fallback method is called with incorrect value. 

Test scenario:
* Deploy MP FT service with:
{code}
@Asynchronous
@Retry(retryOn = IOException.class)
    @CircuitBreaker(failOn = IOException.class, requestVolumeThreshold = 5, successThreshold = 3, delay = 2, delayUnit = ChronoUnit.SECONDS, failureRatio = 0.75)
    @Fallback(fallbackMethod = "processFallback")
    public CompletionStage<MyConnection> retryCircuitBreaker(int counter) throws IOException {
        System.out.println("retryCircuitBreaker - called - " + counter);
        if (counter % 4 != 0) { // 3/4 requests trigger IOException
            System.out.println("retryCircuitBreaker - called - " + counter + " throwing exception");
            throw new IOException("Simulated IOException");
        }
        System.out.println("retryCircuitBreaker - called - " + counter + " success");
        return CompletableFuture.completedFuture(new MyConnection() {
            @Override
            public String getData() {
                return "Hello from @Retry @CircuitBreaker method" + counter;
            }
        });
    }

    private CompletionStage<MyConnection> processFallback(int counter) {
        System.out.println("processFallback - returned url counter: " + counter);
        return CompletableFuture.completedFuture(new MyConnection() {
            @Override
            public String getData() {
                return "Fallback Hello" + counter;
            }
        });
    }
{code}
* Sends 16 parallel requests. Every 4th requests pass (including 0th one as there is modulo 4), and 12 invocations fail on IOException.
* Try on more request and check that @Fallback method was called as circuit is open

Expected result:
Circuit gets opened and @Fallback method is called. 

Actual Result:
Circuit is not opened and @Fallback method is called. 

  was:
MP FT does behave correctly in case when there is @CircuitBreaker, @Fallback, @Retry and @Asynchronous on service method. @CircuitBreaker does not get opened based on its configuration and @Fallback method is called with incorrect value. 

Test scenario:
* Deploy MP FT service with:
{code}
@Asynchronous
@Retry(retryOn = IOException.class)
    @CircuitBreaker(failOn = IOException.class, requestVolumeThreshold = 5, successThreshold = 3, delay = 2, delayUnit = ChronoUnit.SECONDS, failureRatio = 0.75)
    @Fallback(fallbackMethod = "processFallback")
    public CompletionStage<MyConnection> retryCircuitBreaker(int counter) throws IOException {
        System.out.println("retryCircuitBreaker - called - " + counter);
        if (counter % 4 != 0) { // 3/4 requests trigger IOException
            System.out.println("retryCircuitBreaker - called - " + counter + " throwing exception");
            throw new IOException("Simulated IOException");
        }
        System.out.println("retryCircuitBreaker - called - " + counter + " success");
        return CompletableFuture.completedFuture(new MyConnection() {
            @Override
            public String getData() {
                return "Hello from @Retry @CircuitBreaker method" + counter;
            }
        });
    }

    private CompletionStage<MyConnection> processFallback(int counter) {
        System.out.println("processFallback - returned url counter: " + counter);
        return CompletableFuture.completedFuture(new MyConnection() {
            @Override
            public String getData() {
                return "Fallback Hello" + counter;
            }
        });
    }
{code}
* Sends 16 parallel requests. Every 4th requests pass (including 0th one as there is modulo 4), and 12 invocations fail on IOException.
* Try on more request and check that @Fallback method was called as circuit is open

Expected result:
Circuit gets opened and @Fallback method is called. 

Actual Result:
Circuit is not opened and @Fallback method is called. 



> MP Fault Tolerance - unexpected behaviour @Fallback method calls with @CircuitBreaker
> -------------------------------------------------------------------------------------
>
>                 Key: WFWIP-307
>                 URL: https://issues.redhat.com/browse/WFWIP-307
>             Project: WildFly WIP
>          Issue Type: Bug
>          Components: MP Fault Tolerance
>            Reporter: Miroslav Novak
>            Assignee: Radoslav Husar
>            Priority: Blocker
>
> MP FT does not behave correctly in case when there is @CircuitBreaker, @Fallback, @Retry and @Asynchronous on service method. @CircuitBreaker does not get opened based on its configuration and @Fallback method is called with incorrect value. 
> Test scenario:
> * Deploy MP FT service with:
> {code}
> @Asynchronous
> @Retry(retryOn = IOException.class)
>     @CircuitBreaker(failOn = IOException.class, requestVolumeThreshold = 5, successThreshold = 3, delay = 2, delayUnit = ChronoUnit.SECONDS, failureRatio = 0.75)
>     @Fallback(fallbackMethod = "processFallback")
>     public CompletionStage<MyConnection> retryCircuitBreaker(int counter) throws IOException {
>         System.out.println("retryCircuitBreaker - called - " + counter);
>         if (counter % 4 != 0) { // 3/4 requests trigger IOException
>             System.out.println("retryCircuitBreaker - called - " + counter + " throwing exception");
>             throw new IOException("Simulated IOException");
>         }
>         System.out.println("retryCircuitBreaker - called - " + counter + " success");
>         return CompletableFuture.completedFuture(new MyConnection() {
>             @Override
>             public String getData() {
>                 return "Hello from @Retry @CircuitBreaker method" + counter;
>             }
>         });
>     }
>     private CompletionStage<MyConnection> processFallback(int counter) {
>         System.out.println("processFallback - returned url counter: " + counter);
>         return CompletableFuture.completedFuture(new MyConnection() {
>             @Override
>             public String getData() {
>                 return "Fallback Hello" + counter;
>             }
>         });
>     }
> {code}
> * Sends 16 parallel requests. Every 4th requests pass (including 0th one as there is modulo 4), and 12 invocations fail on IOException.
> * Try on more request and check that @Fallback method was called as circuit is open
> Expected result:
> Circuit gets opened and @Fallback method is called. 
> Actual Result:
> Circuit is not opened and @Fallback method is called. 



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list