File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -294,10 +294,15 @@ wait_for_leader(_Timeout, 0) ->
294294wait_for_leader (Timeout , Retries ) ->
295295 rabbit_log :info (" Waiting for Khepri leader for ~tp ms, ~tp retries left" ,
296296 [Timeout , Retries - 1 ]),
297- Options = #{timeout => Timeout ,
298- favor => low_latency },
299- case khepri :exists (? STORE_ID , [], Options ) of
300- Exists when is_boolean (Exists ) ->
297+ % % We use a command (delete) rather than a query to check that a leader
298+ % % has been elected. Khepri defaults to running queries against the local
299+ % % member and local queries do not require an elected leader. In order to
300+ % % apply a command though, the cluster must have a leader. So to await
301+ % % leadership we send a command that should no-op: a delete of some node
302+ % % that we will never use.
303+ Options = ? DEFAULT_COMMAND_OPTIONS #{timeout => Timeout },
304+ case khepri :delete (? STORE_ID , [does_not_exist ], Options ) of
305+ ok ->
301306 rabbit_log :info (" Khepri leader elected" ),
302307 ok ;
303308 {error , timeout } -> % % Khepri >= 0.14.0
You can’t perform that action at this time.
0 commit comments