Skip to content

Commit 554685f

Browse files
Sarah Hassanmeta-codesync[bot]
authored andcommitted
Update is_data_replica to include non-voting participants
Summary: This change updates `is_data_replica/2` to correctly identify all participants that receive data replication, including both voting members and non-voting participants. Previously, `is_data_replica/2` only checked the membership list (voting members: full members + witnesses), which excluded non-voting participants that also receive data replication. The function now checks the participants list instead, which includes all nodes that participate in the cluster. The new implementation defines data replicas as all participants except witnesses, which correctly includes: - Full members (voting + data replication) - Non-voting participants (no voting + data replication) While excluding witnesses (voting + no data replication). This aligns with the RAFT configuration model where: - Participants = all cluster nodes (voting members + non-voting participants) - Membership = voting members only (full members + witnesses) - Data replicas = participants that receive replication (participants - witnesses) Reviewed By: hsun324 Differential Revision: D87658062 fbshipit-source-id: 17ad5b8ffc2a0facc660d0ee9c1e11412a1046fb
1 parent 56f3cdf commit 554685f

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/wa_raft_server.erl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -389,18 +389,12 @@ get_config_witnesses(_) ->
389389
[].
390390

391391
-spec is_data_replica(Identity :: #raft_identity{}, Config :: config() | config_all()) -> boolean().
392-
is_data_replica(#raft_identity{name = Name, node = Node}, #{version := 1, membership := Membership, witness := Witnesses}) ->
393-
lists:member({Name, Node}, Membership) and not lists:member({Name, Node}, Witnesses);
394-
is_data_replica(#raft_identity{name = Name, node = Node}, #{version := 1, membership := Membership}) ->
395-
lists:member({Name, Node}, Membership);
396-
is_data_replica(_, _) ->
397-
false.
392+
is_data_replica(Identity, Config) ->
393+
lists:member(Identity, get_config_participants(Config)) and not lists:member(Identity, get_config_witnesses(Config)).
398394

399395
-spec is_witness(Identity :: #raft_identity{}, Config :: config() | config_all()) -> boolean().
400-
is_witness(#raft_identity{name = Name, node = Node}, #{version := 1, witness := Witnesses}) ->
401-
lists:member({Name, Node}, Witnesses);
402-
is_witness(_, _) ->
403-
false.
396+
is_witness(Identity, Config) ->
397+
lists:member(Identity, get_config_witnesses(Config)).
404398

405399
%% Create a new cluster configuration with no members.
406400
%% Without any members, this cluster configuration should not be used as

0 commit comments

Comments
 (0)