You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/03/12 17:15:00 UTC

[GitHub] davisp commented on a change in pull request #1187: [WIP] Couchdb 3326 clustered purge

davisp commented on a change in pull request #1187: [WIP] Couchdb 3326 clustered purge
URL: https://github.com/apache/couchdb/pull/1187#discussion_r173876314
 
 

 ##########
 File path: src/couch_index/src/couch_index_plugin_couch_db.erl
 ##########
 @@ -0,0 +1,42 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_index_plugin_couch_db).
+
+-export([
+    before_copy_purge_info/1
+]).
+
+-include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
+
+
+before_copy_purge_info(DbName) ->
+    {ok, DDocs} = design_docs(DbName),
+    lists:map(fun(DDoc) ->
+        JsonDDoc = couch_doc:from_json_obj(DDoc),
+        couch_mrview_index:maybe_create_local_purge_doc(DbName, JsonDDoc)
+    end, DDocs).
+
+%% Internal functions
+
+design_docs(DbName) ->
 
 Review comment:
   @eiri I'm not 100% on what scale you're looking at. Each index will require a corresponding _local doc. The overhead there seems minimal. Writing them during compaction should only happen when we first start a compaction when a purge tree has not been updated. And only if the index hasn't already written the doc.
   
   The reason this exists is purely for the upgrade step so that every index on the database gets its initial state set correctly. When its not an upgrade compaction then we'll not run this step as the design documents will have already been written.
   
   That said I haven't gone through this PR entirely yet so its quite possible we missed that bit of intent here. But generally speaking that's the idea.
   
   Also the reason we can't do it during index compactions is that a) not all indexes compact and b) index compaction isn't the issue. The issue would be if we were to drop purge requests during db compaction that an index hasn't processed. So this is just intedned to be "before first compaction, generate an initial state for all known indexes" so we don't invalidate indexes.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services