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

Race condition with registration events in Eureka server

Open
#2,659 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I believe I have found a race condition with the spring-cloud-netflix-eureka-server (Edgware) module concerning registration of instances.
When an instance on the Eureka server registers, an EurekaInstanceRegisteredEvent is emitted by InstanceRegistry. Unfortunately, this event is emitted before the actual registration has taken place in the InstanceRegistry itself. Typically, one would handle this event and rely on the fact that the registration process has been completed to be able to query the registry for the new state. Especially since the class is called EurekaInstanceRegister_ED_Event.

If you have a look at the source ode of org.springframework.cloud.netflix.eureka.server.InstanceRegistry line 85+86 you can see that the event is published before super.register is called.

This behaviour affects all three events EurekaInstanceRegisteredEvent, EurekaInstanceCanceledEvent and EurekaInstanceRenewedEvent.

I am happy to provide a pull request that fixes this, unless this behaviour is on purpose (for some reason).

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 reading org.springframework.cloud.netflix.eureka.server.InstanceRegistry around lines 85-86 and trace how registration, cancellation, and renewal events are published relative to the superclass operation. Verify whether each event can observe the registry's updated state. Done means all three events are emitted only after their corresponding registry operation has completed, with regression coverage for the ordering.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.