- Notifications
You must be signed in to change notification settings - Fork 4k
Make rabbitmqctl delete_queue more robust #9324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michaelklishin merged 17 commits into rabbitmq:main from Ayanda-D:robust-ctl-delete-queue Sep 11, 2023
Merged
Changes from all commits
Commits
Show all changes
17 commits Select commit Hold shift + click to select a range
d899459 implement rabbit_amqqueue:delete_with/{4,6} api
Ayanda-D 63165c0 update channel to use delete_with on queue.delete handling
Ayanda-D 84e924b update ctl delete_queue command to use delete_with api
Ayanda-D f0a29c9 make kill_queue/{2,3} and kill_queue_hard/{2,3} from crashing_queues_…
Ayanda-D dd900b4 fix unrelated typo
Ayanda-D 3502929 ctl delete_queue command test case for a crashed queue
Ayanda-D 5717bcd refactor and move remote_sup_child/2 to rabbit_misc
Ayanda-D 3ac283d use queue resource names for new queue operations (changes the api sp…
Ayanda-D 7daaee8 formatting
Ayanda-D a213540 be extra defensive on the kill_queue/2 api
Ayanda-D 0674cdf make rabbit_control_misc:await_state/4 api more consistent on the que…
Ayanda-D 4e8474a use descriptive macros instead of magic numbers in await_new_pid/3 an…
Ayanda-D 1097ebe improve error handling for non-existent queues in pid_or_crashed/2 ap…
Ayanda-D 290c1c0 add test for ctl delete_queue for a stopped queue
Ayanda-D 1d16388 new rabbit_amqqueue_control for queue related control operations and …
Ayanda-D 3bd51f7 try revert extra_apps generated and added on bazel run gazelle to fix…
Ayanda-D 779c9e4 formatting and ensure use sup specs in rabbit_types
Ayanda-D File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,57 @@ | ||
| % 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-2023 VMware, Inc. or its affiliates. All rights reserved. | ||
| %% | ||
| | ||
| -module(rabbit_amqqueue_control). | ||
| | ||
| -export([await_new_pid/3, await_state/3, await_state/4]). | ||
| | ||
| -define(DEFAULT_AWAIT_STATE_TIMEOUT, 30000). | ||
| -define(AWAIT_NEW_PID_DELAY_INTERVAL, 10). | ||
| -define(AWAIT_STATE_DELAY_INTERVAL, 100). | ||
| -define(AWAIT_STATE_DELAY_TIME_DELTA, 100). | ||
| | ||
| -include_lib("rabbit_common/include/resource.hrl"). | ||
| | ||
| -spec await_new_pid(node(), rabbit_amqqueue:name(), pid()) -> pid(). | ||
| await_new_pid(Node, QRes = #resource{kind = queue}, OldPid) -> | ||
| case rabbit_amqqueue:pid_or_crashed(Node, QRes) of | ||
| OldPid -> timer:sleep(?AWAIT_NEW_PID_DELAY_INTERVAL), | ||
| await_new_pid(Node, QRes, OldPid); | ||
| New -> New | ||
| end. | ||
| | ||
| -spec await_state(node(), rabbit_amqqueue:name() | binary(), atom()) -> 'ok'. | ||
| await_state(Node, QName, State) when is_binary(QName) -> | ||
| QRes = rabbit_misc:r(<<"/">>, queue, QName), | ||
| await_state(Node, QRes, State); | ||
| await_state(Node, QRes = #resource{kind = queue}, State) -> | ||
| await_state(Node, QRes, State, ?DEFAULT_AWAIT_STATE_TIMEOUT). | ||
| | ||
| -spec await_state(node(), rabbit_amqqueue:name() | binary(), atom(), integer()) -> 'ok'. | ||
| await_state(Node, QName, State, Time) when is_binary(QName) -> | ||
| QRes = rabbit_misc:r(<<"/">>, queue, QName), | ||
| await_state(Node, QRes, State, Time); | ||
| await_state(Node, QRes = #resource{kind = queue}, State, Time) -> | ||
| case state(Node, QRes) of | ||
| State -> | ||
| ok; | ||
| Other -> | ||
| case Time of | ||
| 0 -> exit({timeout_awaiting_state, State, Other}); | ||
| _ -> timer:sleep(?AWAIT_STATE_DELAY_INTERVAL), | ||
| await_state(Node, QRes, State, Time - ?AWAIT_STATE_DELAY_TIME_DELTA) | ||
| end | ||
| end. | ||
| | ||
| state(Node, QRes = #resource{virtual_host = VHost, kind = queue}) -> | ||
| Infos = rpc:call(Node, rabbit_amqqueue, info_all, [VHost, [name, state]]), | ||
| fetch_state(QRes, Infos). | ||
| | ||
| fetch_state(_QRes, []) -> undefined; | ||
| fetch_state(QRes, [[{name, QRes}, {state, State}] | _]) -> State; | ||
| fetch_state(QRes, [[{name, _}, {state, _State}] | Rem]) -> | ||
| fetch_state(QRes, Rem). |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.