@@ -959,18 +959,11 @@ impl<D: AsyncDB, M: MakeConnection<Conn = D>> Runner<D, M> {
959959 & mut self ,
960960 record : Record < D :: ColumnType > ,
961961 ) -> 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 {
969964 return self . run_async_no_retry ( record) . await ;
970- }
965+ } ;
971966
972- // Retry for `retry.attempts` times. The parser ensures that `retry.attempts` must > 0.
973- let retry = retry. unwrap ( ) ;
974967 let mut last_error = None ;
975968 for _ in 0 ..retry. attempts {
976969 let result = self . run_async_no_retry ( record. clone ( ) ) . await ;
@@ -1530,7 +1523,18 @@ impl<D: AsyncDB, M: MakeConnection<Conn = D>> Runner<D, M> {
15301523 ) ;
15311524 continue ;
15321525 }
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+
15341538 let record = update_record_with_output (
15351539 & record,
15361540 & record_output,
0 commit comments