@@ -959,18 +959,11 @@ impl<D: AsyncDB, M: MakeConnection<Conn = D>> Runner<D, M> {
959
959
& mut self ,
960
960
record : Record < D :: ColumnType > ,
961
961
) -> Result < RecordOutput < D :: ColumnType > , TestError > {
962
- let retry = match & record {
963
- Record :: Statement { retry, .. } => retry. clone ( ) ,
964
- Record :: Query { retry, .. } => retry. clone ( ) ,
965
- Record :: System { retry, .. } => retry. clone ( ) ,
966
- _ => None ,
967
- } ;
968
- if retry. is_none ( ) {
962
+ // The parser ensures that `retry.attempts` must be > 0.
963
+ let Some ( retry) = record. retry_config ( ) else {
969
964
return self . run_async_no_retry ( record) . await ;
970
- }
965
+ } ;
971
966
972
- // Retry for `retry.attempts` times. The parser ensures that `retry.attempts` must > 0.
973
- let retry = retry. unwrap ( ) ;
974
967
let mut last_error = None ;
975
968
for _ in 0 ..retry. attempts {
976
969
let result = self . run_async_no_retry ( record. clone ( ) ) . await ;
@@ -1530,7 +1523,18 @@ impl<D: AsyncDB, M: MakeConnection<Conn = D>> Runner<D, M> {
1530
1523
) ;
1531
1524
continue ;
1532
1525
}
1533
- let record_output = self . apply_record ( record. clone ( ) ) . await ;
1526
+
1527
+ // If a retry configuration is specified, it is safe run the record with retries
1528
+ let record_output = if record. retry_config ( ) . is_some ( ) {
1529
+ // Exhaust all possible retries first before applying the record
1530
+ match self . run_async ( record. clone ( ) ) . await {
1531
+ Ok ( record_output) => record_output,
1532
+ Err ( _) => self . apply_record ( record. clone ( ) ) . await ,
1533
+ }
1534
+ } else {
1535
+ self . apply_record ( record. clone ( ) ) . await
1536
+ } ;
1537
+
1534
1538
let record = update_record_with_output (
1535
1539
& record,
1536
1540
& record_output,
0 commit comments