[JAVA-3911] Race condition on server description access Created: 16/Dec/20  Updated: 28/Oct/23  Resolved: 06/Jan/21

Status: Closed
Project: Java Driver
Component/s: Cluster Management
Affects Version/s: None
Fix Version/s: 4.2.0

Type: Bug Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: planned-maintenance-detectable-bug
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Testing has uncovered a race condition, mostly affecting retryable reads and writes, in which the ServerDescription in DefaultServer does not reflect the current state of the ClusterDescription. This server description is used to make decisions on whether to retry the operation, and as a result can make the wrong decision.

Specifically, the ServerDescription is in the CONNECTING state even after a successful selection of that server. There are a couple of ways we might fix it:

  1. Find and fix the race condition
  2. Make all decisions based on the ConnectionDescription. Stop tracking ServerDescription independently in DefaultServer
  3. Cache the ServerDescription from the ClusterDescription at the time the server was selected


 Comments   
Comment by Githook User [ 06/Jan/21 ]

Author:

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

Message: Fix race condition accessing ServerDescription

Further reduce the possibility of introducing a race
by removing the Server#getDescription method

JAVA-3911
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/8d78ec955d39a2e1295960a35d4b14b74cc34fdb

Comment by Githook User [ 06/Jan/21 ]

Author:

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

Message: Fix race condition accessing ServerDescription

This change guarantees that any operation accessing the ServerDescription
via ConnectionSource will see a Server Description that is valid
(i.e consistent with the state of the server when it was selected), though
perhaps stale, depending on how long the ConnectionSource is retained.

JAVA-3911
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/115244234cf9682bca571b06093c37b82d67f50c

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