[
https://issues.apache.org/jira/browse/COUCHDB-1003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15232859#comment-15232859
]
ASF GitHub Bot commented on COUCHDB-1003:
-----------------------------------------
Github user eiri commented on a diff in the pull request:
https://github.com/apache/couchdb-couch/pull/161#discussion_r59083758
--- Diff: src/couch_file.erl ---
@@ -253,14 +253,23 @@ deleted_filename_suffix() ->
[Y, Mon, D, H, Min, S, couch_uuids:random()]).
nuke_dir(RootDelDir, Dir) ->
+ case config:get_boolean("couchdb", "rename_on_delete", false) of
+ true -> couch_server:delete_file(RootDelDir, Dir, []);
+ false -> delete_dir(RootDelDir, Dir)
+ end.
+
+delete_dir(RootDelDir, Dir) ->
FoldFun = fun(File) ->
Path = Dir ++ "/" ++ File,
case filelib:is_dir(Path) of
true ->
- ok = nuke_dir(RootDelDir, Path),
+ ok = delete_dir(RootDelDir, Path),
file:del_dir(Path);
false ->
- delete(RootDelDir, Path, false)
+ UUID = couch_uuids:random(),
+ DelFile = filename:join([RootDelDir, ".delete", UUID]),
+ file:rename(Path, DelFile),
+ file:delete(DelFile)
--- End diff --
Here is JIRA issue that gives more details on rename-then-delete approach:
https://issues.apache.org/jira/browse/COUCHDB-1003
> deleting db file is asynchronous & file rename in couch_file:delete
> -------------------------------------------------------------------
>
> Key: COUCHDB-1003
> URL: https://issues.apache.org/jira/browse/COUCHDB-1003
> Project: CouchDB
> Issue Type: Question
> Components: Database Core
> Reporter: Benoit Chesneau
>
> I wonder why we spawn the file deletion when we delete a database. On slow io
> machine it introduces latency. I don't see any reason we make this deletion
> asynchronous ?
> About couch_file:delete, we first rename the file before deleting it. Why are
> we doing that ? Is this for windows ?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)