diff options
author | Nick Vatamaniuc <vatamane@apache.org> | 2018-11-27 22:37:38 -0500 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2018-11-28 11:57:42 -0500 |
commit | 369bec2b7db54d6781f4994543f92aa9bf24d28d (patch) | |
tree | 29212c28b2e6d91b7756cc3f443bf206b67732fb | |
parent | eca86229233339bee8bf287975554981269f6b91 (diff) | |
download | couchdb-369bec2b7db54d6781f4994543f92aa9bf24d28d.tar.gz |
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
-rw-r--r-- | src/couch/src/couch_compaction_daemon.erl | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/couch/src/couch_compaction_daemon.erl b/src/couch/src/couch_compaction_daemon.erl index 1a535dba7..fea505e42 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>>, |