vert-x3 / vertx-ignite

Apache License 2.0
35 stars 28 forks source link

NodeListener from HAManagerImpl maybe not invoked (race condition) #117

Closed DemonicTutor closed 3 years ago

DemonicTutor commented 3 years ago

Version

4.1.1

Some versions earlier (at the time the first race-condition fix was commited) it was thread safe because of invocation ordering.

Context

I noticed that the NodeListener from HAManager somethimes does not get invoked and i think its a race between HAManager#init and IgniteClusterManager#join / #leave.

IgniteClusterManager sets a listener in Ignite which is executed on a Ignite-Thread that then schedules back to vertx.executeBlocking.

Now when this Listener triggers and then the worker thread executes this block the NodeListener may not be visible.

Vertx initialization clustered: VertxImpl # clusterManager.join() IgniteClusterManager # join()

VertxImpl # initializeHaManager HAManager # init() IgniteClusterManager # nodeListener()

Do you have a reproducer?

no - i think its pretty obvious.

Steps to reproduce

  1. Start first clustered vertx instance.
  2. logging breakpoint in HAManagerImpl NodeListener
  3. Start / stop more clustered vertx instances joining / leaving first
  4. NodeListener may or may not be set

Extra

OpenJDK 16

zyclonite commented 3 years ago

@DemonicTutor if you want this fix for version 4.1.2, please create a separate PR for the 4.1 branch