Commit b3d445d 1 parent 6ecc56f commit b3d445d Copy full SHA for b3d445d
File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ impl Read {
88
88
let mut buf = bytes:: BytesMut :: new ( ) ;
89
89
90
90
let mut has_had_parsing_error = false ;
91
+ let mut transient_errors = 0 ;
91
92
92
93
while records_bytes < target_bytes {
93
94
let read = match tokio:: select! {
@@ -115,14 +116,15 @@ impl Read {
115
116
continue ;
116
117
}
117
118
} ,
118
- Err ( err) if err. is_transient ( ) => {
119
+ Err ( err) if err. is_transient ( ) && transient_errors < 5 => {
119
120
use rand:: Rng ;
120
121
121
- tracing:: warn!( %err, "Retrying transient read error" ) ;
122
+ transient_errors = transient_errors + 1 ;
123
+
124
+ tracing:: warn!( error = ?err, "Retrying transient read error" ) ;
122
125
let delay = Duration :: from_millis ( rand:: thread_rng ( ) . gen_range ( 300 ..2000 ) ) ;
123
126
tokio:: time:: sleep ( delay) . await ;
124
127
// We can retry transient errors just by continuing to poll the stream
125
- // TODO: We might have a counter here and give up after a few attempts
126
128
continue ;
127
129
}
128
130
Err ( err @ gazette:: Error :: Parsing { .. } ) if !has_had_parsing_error => {
You can’t perform that action at this time.
0 commit comments