Skip to content

Commit 356c9bb

Browse files
Paul Henrichpaulhenrich
authored andcommitted
Fix node crash issue caused by unhandled non-error
When deleting an index, we were only considering 200 a success. However, if we tried to delete an index that didn't exist, solr would return a 404, which we didn't handle. Now we consider that a success as well.
1 parent 912c22a commit 356c9bb

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/yz_index.erl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,10 @@ remove_non_owned_data(Index, Ring) ->
366366
LNonOwned = yz_cover:logical_partitions(Ring, NonOwned),
367367
Queries = [{'query', <<?YZ_PN_FIELD_S, ":", (?INT_TO_BIN(LP))/binary>>}
368368
|| LP <- LNonOwned],
369-
ok = yz_solr:delete(Index, Queries),
369+
case yz_solr:delete(Index, Queries) of
370+
ok -> ok;
371+
{error, nothing_to_delete} -> ok
372+
end,
370373
NonOwned.
371374

372375
-spec schema_name(index_info()) -> schema_name().

src/yz_solr.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ delete(Index, Ops) ->
172172
case ibrowse:send_req(URL, Headers, post, JSON, Opts,
173173
?YZ_SOLR_REQUEST_TIMEOUT) of
174174
{ok, "200", _, _} -> ok;
175+
{ok, "404", _, _} -> {error, nothing_to_delete};
175176
Err -> {error, Err}
176177
end.
177178

0 commit comments

Comments
 (0)