this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Only start manager after config is written

garrison ec6f9141 f667f5e6

+19 -12
+19 -12
lib/servers/coordinator.ex
··· 366 366 state = update_view(state, state.view_number) 367 367 state = commit_storage(state) 368 368 369 - state = start_manager_if_primary(state) 370 - 371 369 SimProcess.send_after(self(), :tick, @tick_interval_ms) 372 370 SimProcess.send_after(self(), :work, @work_interval_ms) 373 371 ··· 459 457 def handle_info({:EXIT, pid, _reason}, %State{} = state) when is_pid(pid) do 460 458 case pid == state.manager_pid do 461 459 true -> 462 - state = 463 - %{state | manager_pid: nil, manager_generation: nil} 464 - |> start_manager_if_primary() 465 - 460 + SimLogger.debug "Coordinator (id=#{state.id}): manager exited (manager_generation=#{state.manager_generation})" 461 + state = %{state | manager_pid: nil, manager_generation: nil} 466 462 {:noreply, state} 467 463 468 464 # TODO: get rid of this once we have a proper supervision tree ··· 502 498 state 503 499 |> send_commit() 504 500 |> send_prepare_if_pending_and_enough_elapsed() 501 + |> maybe_start_manager() 505 502 end 506 503 507 504 defp tick(:backup, _status, %State{} = state) do ··· 661 658 662 659 defp on_request(%State{} = state, command, from) do 663 660 assert state.role == :primary 661 + SimLogger.debug "Coordinator (id=#{state.id}): received command #{inspect(command)}" 664 662 665 663 op_number = state.op_number + 1 666 664 {writes, result} = run_command(state, command) ··· 936 934 937 935 state 938 936 |> send_start_view(other_replica_pids(state)) 939 - |> start_manager_if_primary() 940 937 end 941 938 942 939 defp on_request_start_view(%State{} = state, %RequestStartView{} = rsv) when rsv.view_number != state.view_number do ··· 1199 1196 1200 1197 # Hobbes/Cluster 1201 1198 1202 - defp start_manager_if_primary(%State{role: :backup} = state), do: state 1199 + defp maybe_start_manager(%State{manager_pid: manager_pid} = state) when manager_pid != nil do 1200 + state 1201 + end 1203 1202 1204 - defp start_manager_if_primary(%State{} = state) do 1203 + defp maybe_start_manager(%State{} = state) do 1205 1204 assert state.role == :primary 1206 1205 assert state.manager_pid == nil 1207 1206 assert state.manager_generation == nil 1208 1207 1209 - coordinators = Enum.map(state.replica_ids, &Map.fetch!(state.replica_map, &1)) 1210 - {:ok, manager_pid} = Manager.start_link(%{coordinators: coordinators, primary_coordinator: self()}) 1211 - %{state | manager_pid: manager_pid} 1208 + case scan(state, "config/", "config0") do 1209 + [_ | _] -> 1210 + coordinators = Enum.map(state.replica_ids, &Map.fetch!(state.replica_map, &1)) 1211 + {:ok, manager_pid} = Manager.start_link(%{coordinators: coordinators, primary_coordinator: self()}) 1212 + 1213 + SimLogger.debug "Coordinator (id=#{state.id}) started manager" 1214 + %{state | manager_pid: manager_pid} 1215 + 1216 + [] -> 1217 + state 1218 + end 1212 1219 end 1213 1220 end