Skip to content

Commit ad9340d

Browse files
committed
fix wait master fe ip 10s
1 parent 073fd68 commit ad9340d

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

‎docker/runtime/doris-compose/cluster.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,9 @@ def gen_subnet_prefix16():
140140

141141
def get_master_fe_endpoint(cluster_name):
142142
master_fe_ip_file = get_cluster_path(cluster_name) + "/status/master_fe_ip"
143-
max_retries = 10
144-
for attempt in range(max_retries):
145-
if os.path.exists(master_fe_ip_file):
146-
with open(master_fe_ip_file, "r") as f:
147-
return "{}:{}".format(f.read().strip(), FE_QUERY_PORT)
148-
time.sleep(1)
143+
if os.path.exists(master_fe_ip_file):
144+
with open(master_fe_ip_file, "r") as f:
145+
return "{}:{}".format(f.read().strip(), FE_QUERY_PORT)
149146
try:
150147
cluster = Cluster.load(cluster_name)
151148
LOG.info("master file not exist, master ip get from node 1")

‎docker/runtime/doris-compose/command.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,13 @@ def do_add_node(node_type, add_num, add_ids):
625625
LOG.info("after Waiting for FE master to be elected...")
626626
if cluster.is_cloud and args.sql_mode_node_mgr:
627627
db_mgr = database.get_db_mgr(args.NAME, False)
628-
master_fe_endpoint = CLUSTER.get_master_fe_endpoint(
629-
cluster.name)
628+
master_fe_endpoint = ""
629+
for i in range(10):
630+
master_fe_endpoint = CLUSTER.get_master_fe_endpoint(
631+
cluster.name)
632+
if master_fe_endpoint:
633+
break
634+
time.sleep(1)
630635
# Add FEs except master_fe
631636
for fe in cluster.get_all_nodes(CLUSTER.Node.TYPE_FE):
632637
fe_endpoint = f"{fe.get_ip()}:{CLUSTER.FE_EDITLOG_PORT}"
@@ -1071,7 +1076,8 @@ def parse_cluster_compose_file(cluster_name):
10711076
if services is None:
10721077
return COMPOSE_BAD, {}
10731078
return COMPOSE_GOOD, {
1074-
service: ComposeService(
1079+
service:
1080+
ComposeService(
10751081
service,
10761082
list(service_conf["networks"].values())[0]
10771083
["ipv4_address"], service_conf["image"])

‎docker/runtime/doris-compose/database.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,15 @@ def _exec_query(self, sql, retries=3):
233233
cursor.execute(sql)
234234
fields = [field_md[0] for field_md in cursor.description
235235
] if cursor.description else []
236-
return [dict(zip(fields, row)) for row in cursor.fetchall()]
236+
return [
237+
dict(zip(fields, row)) for row in cursor.fetchall()
238+
]
237239
except Exception as e:
238240
LOG.warn(f"Error occurred: {e}")
239241
if "timed out" in str(e).lower() and attempt < retries - 1:
240-
LOG.warn(f"Query timed out. Retrying {attempt + 1}/{retries}...")
242+
LOG.warn(
243+
f"Query timed out. Retrying {attempt + 1}/{retries}..."
244+
)
241245
self._reset_conn()
242246
else:
243247
raise e

0 commit comments

Comments
 (0)