Add top-level error labels to write concern error#766
Conversation
This will allow the driver to properly retry writes that the server has labeled as a RetryableWriteError. JAVA-4244
| return new MongoNotPrimaryException(response, serverAddress); | ||
| } else if (response.containsKey("writeConcernError")) { | ||
| return createSpecialException(response.getDocument("writeConcernError"), serverAddress, "errmsg"); | ||
| return createSpecialException(response.getDocument("writeConcernError").clone() |
There was a problem hiding this comment.
It's pretty hacky to clone the writeConcernError document so we can append errorLabels to it, but it's the most localized fix. Happy to entertain other ideas though
| import java.net.URISyntaxException; | ||
| import java.util.Collection; | ||
|
|
||
| public class UnifiedRetryableWritesTest extends UnifiedReactiveStreamsTest { |
There was a problem hiding this comment.
These are the first unified retryable writes tests so need new runners for them.
| @@ -0,0 +1,205 @@ | |||
| { | |||
There was a problem hiding this comment.
I added these two new unified tests for this, in scope of already existing DRIVERS-1385 ticket.
|
Sharded tests are failing... Converting to draft while investigation is in progress. |
| return new MongoNotPrimaryException(response, serverAddress); | ||
| } else if (response.containsKey("writeConcernError")) { | ||
| return createSpecialException(response.getDocument("writeConcernError"), serverAddress, "errmsg"); | ||
| BsonDocument writeConcernError = response.getDocument("writeConcernError"); |
There was a problem hiding this comment.
I think this is more complex than it needs to be:
MongoException error = createSpecialException(response.getDocument("writeConcernError"), serverAddress, "errmsg");
for (BsonValue errorLabel : response.getArray("errorLabels", new BsonArray())) {
error.addLabel(errorLabel.asString().getValue());
}
return error;
There was a problem hiding this comment.
That's so much better. Thanks. Added a couple of checks to a conditional protecting the loop. One is necessary for correctness, the other just to document intent.
Done.
This will allow the driver to properly retry writes that the server has labeled as a RetryableWriteError. JAVA-4244
This will allow the driver to properly retry writes that the server has labeled as a RetryableWriteError. JAVA-4244
This will allow the driver to properly retry writes that the server
has labeled as a RetryableWriteError.
JAVA-4244