Skip to content

Commit

Permalink
Put CETS version in cluster name
Browse files Browse the repository at this point in the history
When performing a rolling upgrade e.g. from 6.2.0 to the upcoming 6.2.1,
CETS would crash on all nodes due to version incompatibility.

This can be prevented by putting cets 'Major.Minor' version in the
cluster name, making the two cluster components disjoint during
upgrade.

The only thing to keep in mind is to bump the Major or Minor version
number when there is any incompatibility in the CETS inter-node API.
  • Loading branch information
chrzaszcz committed Apr 9, 2024
1 parent cb92b6a commit f102499
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mongoose_cets_discovery_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@
-spec init(opts()) -> state().
init(Opts = #{cluster_name := ClusterName, node_name_to_insert := Node})
when is_binary(ClusterName), is_binary(Node) ->
Keys = [cluster_name, node_name_to_insert, last_query_info, expire_time, node_ip_binary],
maps:with(Keys, maps:merge(defaults(), Opts)).
Keys = [node_name_to_insert, expire_time, last_query_info, node_ip_binary],
StateOpts = maps:merge(defaults(), maps:with(Keys, Opts)),
StateOpts#{cluster_name => cluster_name_with_vsn(ClusterName)}.

cluster_name_with_vsn(ClusterName) ->
{ok, CetsVsn} = application:get_key(cets, vsn),
[MajorVsn, MinorVsn | _] = string:tokens(CetsVsn, "."),
iolist_to_binary([ClusterName, $-, MajorVsn, $., MinorVsn]).

defaults() ->
#{expire_time => 60 * 60 * 1, %% 1 hour in seconds
Expand Down

0 comments on commit f102499

Please sign in to comment.