-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3263 from rabbitmq/rabbitmq-server-3260
Partially reintroduce locking to mirrored_supervisor (cherry picked from commit cf2c609) Adapted for Erlang 24 compatibility of rabbit_log call sites. Conflicts: deps/rabbit_common/src/mirrored_supervisor.erl
- Loading branch information
1 parent
6e5553c
commit 410925b
Showing
2 changed files
with
98 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
%% This Source Code Form is subject to the terms of the Mozilla Public | ||
%% License, v. 2.0. If a copy of the MPL was not distributed with this | ||
%% file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
%% | ||
%% Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved. | ||
%% | ||
|
||
-module(mirrored_supervisor_locks). | ||
|
||
-export([lock/1, unlock/1]). | ||
|
||
-define(KEY_PREFIX, mirrored_supervisor). | ||
|
||
%% | ||
%% API | ||
%% | ||
|
||
lock(Group) -> | ||
Nodes = nodes(), | ||
%% about 300s, same as rabbit_nodes:lock_retries/0 default | ||
LockId = case global:set_lock({?KEY_PREFIX, Group}, Nodes, 80) of | ||
true -> Group; | ||
false -> undefined | ||
end, | ||
LockId. | ||
|
||
unlock(LockId) -> | ||
Nodes = nodes(), | ||
case LockId of | ||
undefined -> ok; | ||
Value -> global:del_lock({?KEY_PREFIX, Value}, Nodes) | ||
end, | ||
ok. |