diff options
-rw-r--r-- | apps/fabric/src/fabric_doc_open.erl | 5 | ||||
-rw-r--r-- | apps/mem3/src/mem3.erl | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/apps/fabric/src/fabric_doc_open.erl b/apps/fabric/src/fabric_doc_open.erl index 9131c94b..dd4917b9 100644 --- a/apps/fabric/src/fabric_doc_open.erl +++ b/apps/fabric/src/fabric_doc_open.erl @@ -25,16 +25,17 @@ go(DbName, Id, Options) -> [Id, [deleted|Options]]), SuppressDeletedDoc = not lists:member(deleted, Options), R = couch_util:get_value(r, Options, couch_config:get("cluster","r","2")), + RepairOpts = [{r, integer_to_list(mem3:n(DbName))} | Options], Acc0 = {length(Workers), list_to_integer(R), []}, case fabric_util:recv(Workers, #shard.ref, fun handle_message/3, Acc0) of {ok, Reply} -> format_reply(Reply, SuppressDeletedDoc); {error, needs_repair, Reply} -> - spawn(fabric, open_revs, [DbName, Id, all, Options]), + spawn(fabric, open_revs, [DbName, Id, all, RepairOpts]), format_reply(Reply, SuppressDeletedDoc); {error, needs_repair} -> % we couldn't determine the correct reply, so we'll run a sync repair - {ok, Results} = fabric:open_revs(DbName, Id, all, Options), + {ok, Results} = fabric:open_revs(DbName, Id, all, RepairOpts), case lists:partition(fun({ok, #doc{deleted=Del}}) -> Del end, Results) of {[], []} -> {not_found, missing}; diff --git a/apps/mem3/src/mem3.erl b/apps/mem3/src/mem3.erl index 41118d54..1021ee5b 100644 --- a/apps/mem3/src/mem3.erl +++ b/apps/mem3/src/mem3.erl @@ -15,7 +15,7 @@ -module(mem3). -export([start/0, stop/0, restart/0, nodes/0, shards/1, shards/2, - choose_shards/2]). + choose_shards/2, n/1]). -export([compare_nodelists/0, compare_shards/1]). -include("mem3.hrl"). @@ -58,6 +58,10 @@ compare_shards(DbName) -> end, orddict:new(), lists:zip(Replies, GoodNodes)), [{bad_nodes, BadNodes} | Dict]. +-spec n(DbName::iodata()) -> integer(). +n(DbName) -> + length(mem3:shards(DbName, <<"foo">>)). + -spec nodes() -> [node()]. nodes() -> mem3_nodes:get_nodelist(). |