spring-cloud / spring-cloud/spring-cloud-netflix

Ribbon with Spring-retry make an error renewal for ServerStats

Open
#3,131 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
Java
Stars
5k
Forks
2.5k
Avg merge
1d 2h
Merged PRs (30d)
10

Description

hi,

I'm using Feign,Ribbon, and when i import ZipKin ,the Spring-Retry would be impoted because of dependency.
I think i've found a bug when Ribbon Feign work with Spring retry that the LoadBalancerCommand.java will make an error update on a Fail Server. The following is the recurrence .

POM :

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.13.RELEASE</version>
    </parent>        
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>Edgware.SR4</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>

i have two applications( InterfaceApplication TopicApplication ) ,and TopicApplication is two instances work on port 8002 and 8003 .InterfaceApplication will call TopicApplication.

InterfaceApplication yml:

ribbon:
  eureka:
    enabled: true 
  ReadTimeout: 3000
  ConnectTimeout: 5000
  MaxAutoRetries: 0
  MaxAutoRetriesNextServer: 3
  OkToRetryOnAllOperations: false
feign:
  httpclient:
    enabled: true

1、start applications

image

2、make interfaceApplication call TopicApplication,first server choose is 10.2.58.222:8003

image

3、kill 10.2.58.222:8003 , interfaceApplication will retry other server 10.2.58.222:8002, request will be success

LoadBalancerCommand.java#L307

image

4、but uri will be origin server 10.2.58.222:8003 , and serverstat too. the reason i think is server and serverstat create at LoadBanceCommend.java ,but retry execute at RetryTemplate.

image

5、Finally 10.2.58.222:8003 serverstat will be update,not 10.2.58.222:8002

image

and after an error update ,the fail server successiveConnectionFailureCount will be clear ,and change CircuitBreaker status cause subsequent requests lead to a fail server.

main code link :
1、LoadBalancerCommand.java
2、AbstractLoadBalancerAwareClient
3、RetryableFeignLoadBalancer
4、RetryTemplate

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the linked lines in LoadBalancerCommand.java and RetryableFeignLoadBalancer.java, then compare how AbstractLoadBalancerAwareClient and RetryTemplate handle the retry. Reproduce the two-server scenario described in the issue and inspect which server and ServerStats receive the update. Done means the failed server is not incorrectly updated after a retry succeeds on another server.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
api, backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.