Skip to content

Commit 383606b

Browse files
committed
refactor soft deletion of search index
1 parent a8f3ad9 commit 383606b

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/dreyfus/src/clouseau_rpc.erl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
-export([open_index/3]).
2121
-export([await/2, commit/2, get_update_seq/1, info/1, search/2]).
2222
-export([group1/7, group2/2]).
23-
-export([delete/2, update/3, cleanup/1, cleanup/2, rename/1]).
23+
-export([delete/2, soft_delete/1, update/3, cleanup/1, cleanup/2]).
2424
-export([analyze/2, version/0, disk_size/1]).
2525
-export([set_purge_seq/2, get_purge_seq/1, get_root_dir/0, close_lru/0, close_lru/1]).
2626
-export([connected/0]).
@@ -78,16 +78,15 @@ group2(Ref, Args) ->
7878
delete(Ref, Id) ->
7979
rpc(Ref, {delete, couch_util:to_binary(Id)}).
8080

81+
soft_delete(DbName) ->
82+
gen_server:cast({cleanup, clouseau()}, {soft_delete, DbName}).
83+
8184
update(Ref, Id, Fields) ->
8285
rpc(Ref, {update, Id, Fields}).
8386

8487
cleanup(DbName) ->
8588
gen_server:cast({cleanup, clouseau()}, {cleanup, DbName}).
8689

87-
rename(DbName) ->
88-
close_lru(DbName),
89-
gen_server:cast({cleanup, clouseau()}, {rename, DbName}).
90-
9190
cleanup(DbName, ActiveSigs) ->
9291
gen_server:cast({cleanup, clouseau()}, {cleanup, DbName, ActiveSigs}).
9392

src/dreyfus/src/dreyfus_index_manager.erl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ handle_cast({cleanup, DbName}, State) ->
8484
clouseau_rpc:cleanup(DbName),
8585
{noreply, State};
8686

87-
handle_cast({rename, DbName}, State) ->
88-
clouseau_rpc:rename(DbName),
87+
handle_cast({soft_delete, DbName}, State) ->
88+
clouseau_rpc:soft_delete(DbName),
8989
{noreply, State}.
9090

9191
handle_info({'EXIT', FromPid, Reason}, State) ->
@@ -122,10 +122,9 @@ handle_db_event(DbName, deleted, _St) ->
122122
RecoveryEnabled = config:get_boolean("couchdb",
123123
"enable_database_recovery", false),
124124
case RecoveryEnabled of
125-
true ->
126-
clouseau_rpc:close_lru(DbName),
127-
gen_server:cast(?MODULE, {rename, DbName});
128125
false ->
126+
gen_server:cast(?MODULE, {soft_delete, DbName});
127+
true ->
129128
gen_server:cast(?MODULE, {cleanup, DbName})
130129
end,
131130

0 commit comments

Comments
 (0)