First thing to note is that bigcouch development is over, but we can at least
confirm this;
This function fetches all the design docs of the database, grabs all the
signatures from each (you’ll have noticed view filenames look uuid/randomy,
that’s a 'sig'), and then sweeps the dir where all views for the given database
should be and deletes those not in the 'keep' list.
Can you enable debug level logging (curl localhost:5984/_config/log/level -X
PUT -d '"debug"' to *all* bigcouch nodes) and tell us if ;
?LOG_DEBUG("deleting unused view index files: ~p",[DeleteFiles]),
actually gets printed?
B.
On 31 Jan 2014, at 16:09, Vladimir Ralev <[email protected]> wrote:
> Hi guys,
>
> bigcouch 0.4.2 has the following code that handles view cleanup:
>
> cleanup_index_files(Db) ->
>
> % load all ddocs
>
> {ok, DesignDocs} = couch_db:get_design_docs(Db),
>
>
> % make unique list of group sigs
>
> Sigs = lists:map(fun(#doc{id = GroupId}) ->
>
> {ok, Info} = get_group_info(Db, GroupId),
>
> ?b2l(couch_util:get_value(signature, Info))
>
> end, [DD||DD <- DesignDocs, DD#doc.deleted == false]),
>
>
> FileList = list_index_files(Db),
>
>
> DeleteFiles =
>
> if length(Sigs) =:= 0 ->
>
> FileList;
>
> true ->
>
> % regex that matches all ddocs
>
> RegExp = "("++ string:join(Sigs, "|") ++")",
>
>
> % filter out the ones in use
>
> [FilePath || FilePath <- FileList,
>
> re:run(FilePath, RegExp, [{capture, none}]) =:= nomatch]
>
> end,
>
>
> % delete unused files
>
> ?LOG_DEBUG("deleting unused view index files: ~p",[DeleteFiles]),
>
> RootDir = couch_config:get("couchdb", "view_index_dir"),
>
> [couch_file:delete(RootDir,File,false)||File <- DeleteFiles],
>
> ok.
>
>
> From here
> https://github.com/cloudant/bigcouch/blob/master/apps/couch/src/couch_view.erl#L84
>
> It's supposed to delete only unused views, but in my case it deletes
> everything and then starts building from scratch. Can you help me
> understand the condition used here to filter the files that are currently
> in use? How is the regex supposed to work.