From 1d902c4d90459a980571fa53640427e382a59c79 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 9 Apr 2021 11:49:56 -0400 Subject: [PATCH] Backoff if trying to find a currently live server --- confluent_server/confluent/collective/manager.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/collective/manager.py b/confluent_server/confluent/collective/manager.py index 489062b0..dfe87baa 100644 --- a/confluent_server/confluent/collective/manager.py +++ b/confluent_server/confluent/collective/manager.py @@ -43,6 +43,7 @@ currentleader = None follower = None retrythread = None failovercheck = None +initting = True class ContextBool(object): def __init__(self): @@ -500,7 +501,7 @@ def handle_connection(connection, cert, request, local=False): connection.close() return myself = connection.getsockname()[0] - if connecting.active: + if connecting.active or initting: tlvdata.send(connection, {'error': 'Connecting right now', 'backoff': True}) connection.close() @@ -542,6 +543,7 @@ def handle_connection(connection, cert, request, local=False): connection.sendall(cfgdata) #tlvdata.send(connection, {'tenants': 0}) # skip the tenants for now, # so far unused anyway + connection.settimeout(90) if not cfm.relay_slaved_requests(drone, connection): log.log({'info': 'All clients have disconnected, starting recovery process', 'subsystem': 'collective'}) @@ -720,6 +722,8 @@ def schedule_rebalance(): def start_collective(): global follower global retrythread + global initting + initting = True retrythread = None try: cfm.membership_callback = schedule_rebalance @@ -764,3 +768,5 @@ def start_collective(): if retrythread is None: retrythread = eventlet.spawn_after(random.random(), start_collective) + finally: + initting = False