[JAVA-4449] Publish cluster changed events in the order that they were applied Created: 23/Jan/22  Updated: 28/Oct/23  Resolved: 28/Jan/22

Status: Closed
Project: Java Driver
Component/s: Monitoring
Affects Version/s: None
Fix Version/s: 4.5.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
causes JAVA-5185 Fix the ClusterListener, ServerListen... Closed
Related
Case:
Backwards Compatibility: Fully Compatible
Documentation Changes: Not Needed

 Description   

Currently, {{ClusterDescriptionChangedEvent}}s are published to any registered {{ClusterListener}}s in an undefined order. In particular, it's possible that an event A that was applied to the internally-tracked state after an event B could appear to be publish before (or concurrent with) event B.

This makes it impossible for ClusterListener implementations to use the events to track the current state of the cluster.

The driver should ensure the following properties:

  • Event publication is serialized. {{ClusterListener implementations should not have to apply their own synchronization
  • Events are published in the order that they were applied to the cluster state

Also, see https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring-monitoring.rst#event-order-and-concurrency



 Comments   
Comment by Githook User [ 28/Jan/22 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@mongodb.com', 'username': 'jyemin'}

Message: Ensure server discovery and monitoring events are published in order (#860)

  • Ensure events are ordered according to how they are applied to driver state
  • Publish all events to application listeners one at a time, on a separate thread
  • Document and ensure that cluster event listeners are not required to be thread safe

JAVA-4449
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/f6b540c6815abc0966be790cda9ad9358366f239

Generated at Thu Feb 08 09:02:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.