You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2023/01/09 17:06:55 UTC
[couchdb] branch pass-through-forbidden-bdu-exception created (now 7ebe04c9f)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch pass-through-forbidden-bdu-exception
in repository https://gitbox.apache.org/repos/asf/couchdb.git
at 7ebe04c9f Fix handling forbidden exceptions from workers in fabric_doc_update
This branch includes the following new commits:
new 7ebe04c9f Fix handling forbidden exceptions from workers in fabric_doc_update
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb] 01/01: Fix handling forbidden exceptions from workers in fabric_doc_update
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch pass-through-forbidden-bdu-exception
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 7ebe04c9f4332e129c2992f5c4f1fbe2fe5998b8
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Mon Jan 9 12:02:36 2023 -0500
Fix handling forbidden exceptions from workers in fabric_doc_update
Previously we handled `{bad_request, Msg}` but not `{forbidden, Msg}`, so a
`before_doc_update` handler which wanted to emulate the VDU `forbidden`
response ended up crashing with an unhandled clause instead.
(Note: The replicator doc validation BDU wasn't affected as those BDU calls are
made directly from fabric since `*_replicator` shards are "special" system
dbs).
---
src/fabric/src/fabric_doc_update.erl | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/fabric/src/fabric_doc_update.erl b/src/fabric/src/fabric_doc_update.erl
index b7b9e5972..77b424911 100644
--- a/src/fabric/src/fabric_doc_update.erl
+++ b/src/fabric/src/fabric_doc_update.erl
@@ -110,6 +110,8 @@ handle_message({not_found, no_db_file} = X, Worker, Acc0) ->
handle_message({ok, [X || _D <- Docs]}, Worker, Acc0);
handle_message({bad_request, Msg}, _, _) ->
throw({bad_request, Msg});
+handle_message({forbidden, Msg}, _, _) ->
+ throw({forbidden, Msg});
handle_message({request_entity_too_large, Entity}, _, _) ->
throw({request_entity_too_large, Entity}).
@@ -351,7 +353,8 @@ doc_update_test_() ->
fun extend_tree_forbid/0,
fun other_errors_one_forbid/0,
fun one_error_two_forbid/0,
- fun one_success_two_forbid/0
+ fun one_success_two_forbid/0,
+ fun worker_before_doc_update_forbidden/0
]
}.
@@ -751,6 +754,21 @@ one_success_two_forbid() ->
{error, [{Doc1, {ok, Doc1}}, {Doc2, {Doc2, {forbidden, <<"not allowed">>}}}]}, Reply
).
+worker_before_doc_update_forbidden() ->
+ Doc1 = #doc{revs = {1, [<<"foo">>]}},
+ Docs = [Doc1],
+ Shards =
+ mem3_util:create_partition_map("foo", 3, 1, ["node1", "node2", "node3"]),
+ GroupedDocs = group_docs_by_shard_hack(<<"foo">>, Shards, Docs),
+ Acc = {
+ length(Shards),
+ length(Docs),
+ list_to_integer("2"),
+ GroupedDocs,
+ dict:from_list([{Doc, []} || Doc <- Docs])
+ },
+ ?assertThrow({forbidden, <<"msg">>}, handle_message({forbidden, <<"msg">>}, hd(Shards), Acc)).
+
% needed for testing to avoid having to start the mem3 application
group_docs_by_shard_hack(_DbName, Shards, Docs) ->
dict:to_list(