Skip to content

Commit

Permalink
Ensure Ra servers are properly deleted from the dets table
Browse files Browse the repository at this point in the history
when ra_directory:unregister_name/2 is called when a server
has never been started on the system.
  • Loading branch information
kjnilsson committed Jul 19, 2024
1 parent f686d9c commit 3e102b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ra_directory.erl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ unregister_name(#{directory := Directory,
ok = dets:delete(DirRev, ServerName),
UId;
[] ->
_ = dets:select_delete(DirRev, [{{'_', UId}, [], [true]}]),
UId
end.

Expand Down
6 changes: 4 additions & 2 deletions test/ra_directory_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ end_per_testcase(_TestCase, _Config) ->

basics(_Config) ->
ok = ra_directory:init(?SYS),
UId = <<"test1">>,
UId = atom_to_binary(?FUNCTION_NAME),
Self = self(),
ok = ra_directory:register_name(?SYS, UId, Self, undefined,
test1, <<"test_cluster_name">>),
Expand All @@ -92,11 +92,13 @@ basics(_Config) ->

persistence(_Config) ->
ok = ra_directory:init(?SYS),
UId = <<"test1">>,
UId = atom_to_binary(?FUNCTION_NAME),
Self = self(),
ok = ra_directory:register_name(?SYS, UId, Self, undefined, test1, <<"name">>),
UId = ra_directory:uid_of(?SYS, test1),
ok = ra_directory:deinit(?SYS),
ok = ra_directory:init(?SYS),
UId = ra_directory:uid_of(?SYS, test1),
UId = ra_directory:unregister_name(?SYS, UId),
?assertEqual([], ra_directory:list_registered(?SYS)),
ok.

0 comments on commit 3e102b9

Please sign in to comment.