Skip to content

Commit 32ea06f

Browse files
committed
fix HA launch
1 parent fbfe6db commit 32ea06f

1 file changed

Lines changed: 35 additions & 3 deletions

File tree

charts/memgraph-high-availability/templates/cluster-setup.yaml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,37 @@ spec:
9393
local query="$2"
9494
local max_attempts=20
9595
local attempt=0
96+
local show_instances_output
97+
98+
ddl_already_applied() {
99+
local current_step="$1"
100+
show_instances_output="$(run_mgconsole 'SHOW INSTANCES;' 2>/dev/null || true)"
101+
[[ -z "$show_instances_output" ]] && return 1
102+
103+
case "$current_step" in
104+
"ADD COORDINATOR "*)
105+
local coordinator_id="${current_step##* }"
106+
[[ "$show_instances_output" == *"\"coordinator_${coordinator_id}\""* ]]
107+
;;
108+
"REGISTER INSTANCE "*)
109+
local instance_name="${current_step##* }"
110+
[[ "$show_instances_output" == *"\"${instance_name}\""* ]]
111+
;;
112+
"SET INSTANCE instance_1 TO MAIN")
113+
[[ "$show_instances_output" == *"\"instance_1\""* ]] && [[ "$show_instances_output" == *"\"main\""* ]]
114+
;;
115+
*)
116+
return 1
117+
;;
118+
esac
119+
}
96120
97121
while [ $attempt -lt $max_attempts ]; do
122+
if ddl_already_applied "$step"; then
123+
echo "ℹ️ ${step} already present in cluster state; continuing"
124+
return 0
125+
fi
126+
98127
set +e
99128
local output
100129
output="$(run_mgconsole "$query")"
@@ -112,9 +141,12 @@ spec:
112141
if [[ "$output_lc" == *"already exists"* ]] || \
113142
[[ "$output_lc" == *"already set"* ]] || \
114143
[[ "$output_lc" == *"already a main"* ]] || \
115-
[[ "$output_lc" == *"is already main"* ]]; then
116-
echo "ℹ️ ${step} already applied; continuing"
117-
return 0
144+
[[ "$output_lc" == *"is already main"* ]] || \
145+
[[ "$output_lc" == *"request forwarded to the leader but leader failed with request processing"* ]]; then
146+
if ddl_already_applied "$step"; then
147+
echo "ℹ️ ${step} already applied; continuing"
148+
return 0
149+
fi
118150
fi
119151
120152
attempt=$((attempt+1))

0 commit comments

Comments
 (0)