@@ -560,6 +560,7 @@ _mongoc_write_opmsg (mongoc_write_command_t *command,
560
560
561
561
if (ship_it ) {
562
562
bool is_retryable = parts .is_retryable_write ;
563
+ mongoc_write_err_type_t error_type ;
563
564
564
565
/* Seek past the document offset we have already sent */
565
566
parts .assembled .payload = command -> payload .data + payload_total_offset ;
@@ -589,9 +590,9 @@ _mongoc_write_opmsg (mongoc_write_command_t *command,
589
590
* select a new writable stream and retry. If server selection fails or
590
591
* the selected server does not support retryable writes, fall through
591
592
* and allow the original error to be reported. */
592
- if (! ret && is_retryable &&
593
- (error -> domain == MONGOC_ERROR_STREAM ||
594
- _mongoc_write_is_retryable_error ( & reply ) )) {
593
+ error_type = _mongoc_write_error_get_type ( & reply );
594
+ if (! ret && is_retryable && (error -> domain == MONGOC_ERROR_STREAM ||
595
+ error_type == MONGOC_WRITE_ERR_RETRY )) {
595
596
bson_error_t ignored_error ;
596
597
597
598
/* each write command may be retried at most once */
@@ -1430,13 +1431,14 @@ _mongoc_write_result_complete (
1430
1431
RETURN (!result -> failed && result -> error .code == 0 );
1431
1432
}
1432
1433
1433
- bool
1434
- _mongoc_write_is_retryable_error (const bson_t * reply )
1434
+
1435
+ mongoc_write_err_type_t
1436
+ _mongoc_write_error_get_type (const bson_t * reply )
1435
1437
{
1436
1438
bson_error_t error ;
1437
1439
if (_mongoc_cmd_check_ok_no_wce (
1438
1440
reply , MONGOC_ERROR_API_VERSION_2 , & error )) {
1439
- return false ;
1441
+ return MONGOC_WRITE_ERR_NONE ;
1440
1442
}
1441
1443
1442
1444
switch (error .code ) {
@@ -1447,17 +1449,18 @@ _mongoc_write_is_retryable_error (const bson_t *reply)
1447
1449
case 13436 : /* NotMasterOrSecondary */
1448
1450
case 189 : /* PrimarySteppedDown */
1449
1451
case 91 : /* ShutdownInProgress */
1450
- case 64 : /* WriteConcernFailed */
1451
1452
case 7 : /* HostNotFound */
1452
1453
case 6 : /* HostUnreachable */
1453
1454
case 89 : /* NetworkTimeout */
1454
1455
case 9001 : /* SocketException */
1455
- return true;
1456
+ return MONGOC_WRITE_ERR_RETRY ;
1457
+ case 64 : /* WriteConcernFailed */
1458
+ return MONGOC_WRITE_ERR_WRITE_CONCERN ;
1456
1459
default :
1457
1460
if (strstr (error .message , "not master" ) ||
1458
1461
strstr (error .message , "node is recovering" )) {
1459
- return true ;
1462
+ return MONGOC_WRITE_ERR_RETRY ;
1460
1463
}
1461
- return false ;
1464
+ return MONGOC_WRITE_ERR_OTHER ;
1462
1465
}
1463
1466
}
0 commit comments