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 2018/11/28 16:57:47 UTC
[couchdb] branch master updated: Use fabric to get design docs in
the compaction daemon
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/master by this push:
new 369bec2 Use fabric to get design docs in the compaction daemon
369bec2 is described below
commit 369bec2b7db54d6781f4994543f92aa9bf24d28d
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Tue Nov 27 22:37:38 2018 -0500
Use fabric to get design docs in the compaction daemon
Previously the compaction daemon looked for design docs in each shard file.
This worked well for versions < 2.x, however, for clustered databases design
documents will only be found in their respective shards based on the document
id hashing algorithm. This meant that in a default setup of Q=8 only the views
of one shard range, where the _design document lives, would be compacted.
The fix for this issue is to use fabric to retrive all the design documents for
clustered database.
Issue #1579
---
src/couch/src/couch_compaction_daemon.erl | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/src/couch/src/couch_compaction_daemon.erl b/src/couch/src/couch_compaction_daemon.erl
index 1a535db..fea505e 100644
--- a/src/couch/src/couch_compaction_daemon.erl
+++ b/src/couch/src/couch_compaction_daemon.erl
@@ -239,18 +239,23 @@ maybe_compact_views(DbName, [DDocName | Rest], Config) ->
db_ddoc_names(Db) ->
- FoldFun = fun ddoc_name/2,
- Opts = [{start_key, <<"_design/">>}],
- {ok, DDocNames} = couch_db:fold_docs(Db, FoldFun, [], Opts),
- DDocNames.
-
-ddoc_name(#full_doc_info{id = <<"_design/", _/binary>>, deleted = true}, Acc) ->
- {ok, Acc};
-ddoc_name(#full_doc_info{id = <<"_design/", Id/binary>>}, Acc) ->
- {ok, [Id | Acc]};
-ddoc_name(_, Acc) ->
- {stop, Acc}.
+ case couch_db:get_design_docs(Db) of
+ {ok, DDocs} ->
+ [ddoc_name(DDoc) || DDoc <- DDocs];
+ Error ->
+ ErrMsg = "Could not get design docs for ~p error:~p",
+ couch_log:error(ErrMsg, [couch_db:name(Db), Error]),
+ []
+ end.
+
+% Node local docs will be FDIs while cluster ones will be ejson
+ddoc_name(#full_doc_info{id = <<"_design/", Id/binary>>}) ->
+ Id;
+ddoc_name({Props}) ->
+ DocId = proplists:get_value(<<"_id">>, Props),
+ <<"_design/", GroupName/binary>> = DocId,
+ GroupName.
maybe_compact_view(DbName, GroupId, Config) ->
DDocId = <<"_design/", GroupId/binary>>,