diff options
| author | Michael Klishin <michael@novemberain.com> | 2019-02-16 15:47:54 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-16 15:47:54 +0300 |
| commit | 111773916b2543541414ec5bd9084b97caaf9e5b (patch) | |
| tree | 5137b9ab8e28bae17ebd4f310e08101f056a7fe3 /src | |
| parent | 51569c4dd01ecf68cd74b1ba87f780dbf2b4dc77 (diff) | |
| parent | 13cc3098d82086744c092fb40b8fcf1312bae7f3 (diff) | |
| download | rabbitmq-server-git-111773916b2543541414ec5bd9084b97caaf9e5b.tar.gz | |
Merge pull request #1884 from rabbitmq/allow_binding_if_tables_inconsistent
Do not fail on bind/unbind operations if the binding records are inconsistent.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_binding.erl | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl index 918b5c3ce8..05db4188ba 100644 --- a/src/rabbit_binding.erl +++ b/src/rabbit_binding.erl @@ -49,7 +49,6 @@ -type bind_ok_or_error() :: 'ok' | bind_errors() | rabbit_types:error( - 'binding_not_found' | {'binding_invalid', string(), [any()]}). -type bind_res() :: bind_ok_or_error() | rabbit_misc:thunk(bind_ok_or_error()). -type inner_fun() :: @@ -178,19 +177,15 @@ add(Src, Dst, B, ActingUser) -> lock_resource(Src), lock_resource(Dst), [SrcDurable, DstDurable] = [durable(E) || E <- [Src, Dst]], - case (SrcDurable andalso DstDurable andalso - mnesia:read({rabbit_durable_route, B}) =/= []) of - false -> ok = sync_route(#route{binding = B}, SrcDurable, DstDurable, - fun mnesia:write/3), - x_callback(transaction, Src, add_binding, B), - Serial = rabbit_exchange:serial(Src), - fun () -> - x_callback(Serial, Src, add_binding, B), - ok = rabbit_event:notify( - binding_created, - info(B) ++ [{user_who_performed_action, ActingUser}]) - end; - true -> rabbit_misc:const({error, binding_not_found}) + ok = sync_route(#route{binding = B}, SrcDurable, DstDurable, + fun mnesia:write/3), + x_callback(transaction, Src, add_binding, B), + Serial = rabbit_exchange:serial(Src), + fun () -> + x_callback(Serial, Src, add_binding, B), + ok = rabbit_event:notify( + binding_created, + info(B) ++ [{user_who_performed_action, ActingUser}]) end. -spec remove(rabbit_types:binding()) -> bind_res(). @@ -208,7 +203,10 @@ remove(Binding, InnerFun, ActingUser) -> case mnesia:read(rabbit_route, B, write) of [] -> case mnesia:read(rabbit_durable_route, B, write) of [] -> rabbit_misc:const(ok); - _ -> rabbit_misc:const({error, binding_not_found}) + %% We still delete the binding and run + %% all post-delete functions if there is only + %% a durable route in the database + _ -> remove(Src, Dst, B, ActingUser) end; _ -> case InnerFun(Src, Dst) of ok -> remove(Src, Dst, B, ActingUser); |
