File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ mod imports {
74
74
}
75
75
76
76
const RELOAD_RATE_LIMIT : Duration = Duration :: from_secs ( 10 * 60 ) ;
77
+ const RETRY_INTERVAL_MIN : Duration = Duration :: from_secs ( 60 ) ;
78
+ const RETRY_INTERVAL_MAX : Duration = Duration :: from_secs ( 60 * 60 ) ;
77
79
78
80
use imports:: * ;
79
81
@@ -188,6 +190,8 @@ async fn channel_polling_task(
188
190
) {
189
191
let proxy = InstallerProxy :: new ( & conn) . await . unwrap ( ) ;
190
192
193
+ let mut retry_interval = RETRY_INTERVAL_MIN ;
194
+
191
195
while let Some ( mut channel) = channels
192
196
. try_get ( )
193
197
. and_then ( |chs| chs. into_iter ( ) . find ( |ch| ch. name == name) )
@@ -201,11 +205,26 @@ async fn channel_polling_task(
201
205
202
206
if let Err ( e) = channel. poll ( & proxy, slot_status. as_deref ( ) ) . await {
203
207
warn ! (
204
- "Failed to fetch update for update channel \" {}\" : {}" ,
205
- channel. name, e
208
+ "Failed to fetch update for update channel \" {}\" : {}. Retrying in {}s." ,
209
+ channel. name,
210
+ e,
211
+ retry_interval. as_secs( )
206
212
) ;
213
+
214
+ if retry_interval < RETRY_INTERVAL_MAX {
215
+ sleep ( retry_interval) . await ;
216
+
217
+ // Perform a (limited) exponential backoff on the retry interval to recover
218
+ // fast from short-term issues while also preventing the update server from
219
+ // being DDOSed by excessive retries.
220
+ retry_interval *= 2 ;
221
+
222
+ continue ;
223
+ }
207
224
}
208
225
226
+ retry_interval = RETRY_INTERVAL_MIN ;
227
+
209
228
channels. modify ( |chs| {
210
229
let mut chs = chs?;
211
230
let channel_prev = chs. iter_mut ( ) . find ( |ch| ch. name == name) ?;
You can’t perform that action at this time.
0 commit comments