[JAVA-4541] Java driver returns wrong error code in retryable write Created: 21/Mar/22  Updated: 27/Oct/23  Resolved: 25/Mar/22

Status: Closed
Project: Java Driver
Component/s: Write Operations
Affects Version/s: 3.12.10, 4.3.4
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Matthew Russotto Assignee: Jeffrey Yemin
Resolution: Works as Designed Votes: 0
Labels: internal-user
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File java4541_451_debug_log.txt     Text File java4541_debug_log.txt    
Issue Links:
Depends

 Description   

How to Reproduce

  1. Do a replaceOne for a document and have the server return a NotWritablePrimary error.
  2. When the driver retries, have it hang waiting for write concern
  3. Kill (-9) the server being retried on.
  4. Error returned is com.mongodb.MongoNotPrimaryException, indicating the replace didn't happen, though in fact it may have.

If findOneAndReplace is used instead of replaceOne, a MongoSocketReadException is returned instead. 

 



 Comments   
Comment by Jeffrey Yemin [ 25/Mar/22 ]

The driver works as expected in the 4.5.1 release, so closing this out.

Comment by Jeffrey Yemin [ 21/Mar/22 ]

Spec quote that may be relevant:

If the retry attempt also fails, drivers MUST update their topology according to the SDAM spec (see: Error Handling). If an error would not allow the caller to infer that an attempt was made (e.g. connection pool exception originating from the driver), the original error should be raised. If the retry failed due to another retryable error or some other error originating from the server, that error should be raised instead as the caller can infer that an attempt was made and the second error is likely more relevant (with respect to the current topology state).

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