@@ -214,6 +214,8 @@ impl Handler<CheckBackends> for BackendManagerActor {
214
214
. map ( |( ci, ( db, state) ) | ( ci. clone ( ) , ( db. clone ( ) , state. clone ( ) ) ) )
215
215
. collect :: < Vec < _ > > ( ) ;
216
216
217
+ let config = self . config_addr . clone ( ) ;
218
+
217
219
Box :: pin (
218
220
async move {
219
221
let futs = data_backend_info
@@ -292,7 +294,14 @@ impl Handler<CheckBackends> for BackendManagerActor {
292
294
}
293
295
} ) ;
294
296
let meta_info = join_all ( futs) . await ;
295
- ( data_info, meta_info)
297
+ let cfg = match config. send ( GetConfig ) . await {
298
+ Ok ( cfg) => Some ( cfg) ,
299
+ Err ( e) => {
300
+ error ! ( "Could not get config: {}" , e) ;
301
+ None
302
+ }
303
+ } ;
304
+ ( data_info, meta_info, cfg)
296
305
}
297
306
. into_actor ( self )
298
307
. map ( |res, actor, ctx| {
@@ -314,6 +323,11 @@ impl Handler<CheckBackends> for BackendManagerActor {
314
323
if !( new_state. is_readable ( ) && new_state. is_writeable ( ) ) {
315
324
should_sweep = true ;
316
325
}
326
+ // If the backend is not readable, remove the cached connection to trigger
327
+ // a reconnect.
328
+ if !new_state. is_readable ( ) {
329
+ * possible_con = None ;
330
+ }
317
331
* old_state = new_state
318
332
}
319
333
}
@@ -334,11 +348,16 @@ impl Handler<CheckBackends> for BackendManagerActor {
334
348
if !( new_state. is_readable ( ) && new_state. is_writeable ( ) ) {
335
349
should_sweep = true ;
336
350
}
351
+ // If the backend is not readable, remove the cached connection to trigger
352
+ // a reconnect.
353
+ if !new_state. is_readable ( ) {
354
+ * possible_con = None ;
355
+ }
337
356
* old_state = new_state
338
357
}
339
358
}
340
359
341
- if should_sweep {
360
+ if should_sweep && res . 2 . is_some ( ) {
342
361
// Trigger a sweep of all managed backends, removing those at the end of their
343
362
// (managed) lifetime, and try to reserve new ones in their place.
344
363
actor. replace_backends ( ctx) ;
0 commit comments