Skip to content

Commit 4772163

Browse files
committed
Build ring before publishing pool strategy
marina_pool:sync/3 inserted {token_aware, N} into the foil table before marina_ring:build/1 had compiled marina_ring_utils. A query carrying a routing key in that window resolved the token_aware strategy and called marina_ring_utils:lookup/1 on a module that did not exist yet, crashing the caller with undef instead of getting {error, marina_pool_not_started}. Compile the ring first, so the strategy only becomes visible to callers once the lookup module is loaded. This also applies to topology re-syncs, where the same window reopened on every rebuild.
1 parent 8196eb1 commit 4772163

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/marina_pool.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ sync(Strategy, NewNodes, OldNodes) ->
8282
NewAddrs = [Addr || {Addr, _} <- NewNodes],
8383
lists:foreach(fun stop_node/1, OldAddrs -- NewAddrs),
8484
lists:foreach(fun start_node/1, NewAddrs -- OldAddrs),
85-
rebuild_index(Strategy, NewNodes, length(OldNodes)),
8685
case Strategy of
8786
token_aware -> marina_ring:build(NewNodes);
8887
random -> ok
89-
end.
88+
end,
89+
rebuild_index(Strategy, NewNodes, length(OldNodes)).
9090

9191
%% private
9292
node({random, NodeCount}, undefined) ->

0 commit comments

Comments
 (0)