Skip to content

Commit 10a567d

Browse files
paulhenrichJeetKunDoug
authored andcommitted
Clear out solr-webapp directory when setting up yz_temp dir (#681)
* Clear out solr-webapp directory when setting up yz_temp dir On upgrade the existence of this directory and its cached solr classes can cause yokozuna to fail to start. To prevent this, we double-check the state of the temp directory on start. - Remove redundant test setup now that yz_temp is cleared in production * adjust timeout * Fix eqc tests based on new code in dependencies: - yz_solrq_eqc now needs to mock riak_kv_entropy_manager:get_partition_version/1 - eqc_util needs to set up riak_core_table_owner & initialize riak_core_throttle.
1 parent 9bbb0bf commit 10a567d

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

.thumbs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ build_steps:
66
- make dialyzer
77
merge: false
88
org_mode: true
9-
timeout: 1799
9+
timeout: 1790

riak_test/yz_solr_upgrade_downgrade.erl

-5
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,6 @@ update_yz(Params) ->
348348
NewDataDir = proplists:get_value(new_data_dir, Params),
349349
TimestampStr = timestamp_str(),
350350
%%
351-
%% Move yz_temp out of the way, because it contains cached Solr JAR files
352-
%% and other artifacts.
353-
%%
354-
ok = mv_yz_temp(NewDataDir, TimestampStr),
355-
%%
356351
%% Update the luceneMatchVersion in the Solr config
357352
%%
358353
[ok = modify_solr_config(NewDataDir, binary_to_list(Index)) ||

src/yz_solr_proc.erl

+23-1
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,34 @@ ensure_data_dir(Dir) ->
274274
ok
275275
end.
276276

277+
%% @private
278+
%%
279+
%% @doc Recursively delete target directory. Equivalent to
280+
%% `rm -rf $DIR` at the shell
281+
-spec del_dir_recursive(string()) -> ok | {error, enotdir}.
282+
del_dir_recursive(Path) ->
283+
del_dir_recursive(Path, filelib:is_dir(Path)).
284+
285+
-spec del_dir_recursive(string(), boolean()) -> ok | {error, enotdir}.
286+
del_dir_recursive(DirPath, true) ->
287+
FullPaths = [filename:join(DirPath, FilePath) ||
288+
FilePath <- filelib:wildcard("**", DirPath)],
289+
{Dirs, Files} = lists:partition(fun filelib:is_dir/1, FullPaths),
290+
lists:foreach(fun file:delete/1, Files),
291+
%% Delete directories sorted longest to shortest to ensure we delete leaf
292+
%% directories first.
293+
lists:foreach(fun file:del_dir/1, lists:sort(fun (A,B) -> A > B end, Dirs)),
294+
file:del_dir(DirPath);
295+
del_dir_recursive(_DirPath, _Exists = false) ->
296+
{error, enotdir}.
297+
277298
%% @private
278299
%%
279300
%% @doc Make sure that the temp directory (passed in as `TempDir')
280-
%% exists
301+
%% exists and is new
281302
-spec ensure_temp_dir(string()) -> ok.
282303
ensure_temp_dir(TempDir) ->
304+
del_dir_recursive(filename:join(TempDir, "solr-webapp")),
283305
ok = filelib:ensure_dir(filename:join(TempDir, empty)).
284306

285307
%% @private

test/eqc_util.erl

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ start_mock_components(Options) ->
106106
application:load(lager),
107107
ok = lager:start(),
108108
riak_core_metadata_manager:start_link([{data_dir, "eqc_test_data"}]),
109+
riak_core_table_owner:start_link(),
110+
riak_core_throttle:init(),
109111
riak_core_ring_events:start_link(),
110112
riak_core_ring_manager:start_link(test),
111113
riak_core_ring_manager:setup_ets(test),
@@ -121,6 +123,7 @@ cleanup_mock_components() ->
121123
stop_process(riak_core_ring_manager),
122124
stop_process(riak_core_metadata_manager),
123125
stop_process(riak_kv_entropy_manager),
126+
stop_process(riak_core_table_owner),
124127
application:stop(riak_core),
125128
application:stop(riak_kv),
126129
application:unload(riak_core),

test/yz_solrq_eqc.erl

+1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ setup() ->
219219

220220
meck:new(riak_kv_entropy_manager, [passthrough]),
221221
meck:expect(riak_kv_entropy_manager, get_version, fun() -> 0 end),
222+
meck:expect(riak_kv_entropy_manager, get_partition_version, fun(_) -> 0 end),
222223

223224
meck:new(riak_core_bucket),
224225
meck:expect(riak_core_bucket, get_bucket, fun get_bucket/1),

0 commit comments

Comments
 (0)