-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Soften JVM overload failures #358
Changes from 1 commit
c147db7
894e70d
0c5736a
e823d0d
61d6326
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
-define(DEFAULT_URL, "http://localhost:8983/solr"). | ||
-define(DEFAULT_VCLOCK_N, 1000). | ||
-define(QUERY(Str), {struct, [{'query', Str}]}). | ||
-define(SOLR_TIMEOUT, 60000). | ||
|
||
%% @doc This module provides the interface for making calls to Solr. | ||
%% All interaction with Solr should go through this API. | ||
|
@@ -63,7 +64,7 @@ commit(Core) -> | |
URL = ?FMT("~s/~s/update?~s", [base_url(), Core, Encoded]), | ||
Headers = [{content_type, "application/json"}], | ||
Opts = [{response_format, binary}], | ||
case ibrowse:send_req(URL, Headers, post, JSON, Opts) of | ||
case ibrowse:send_req(URL, Headers, post, JSON, Opts, ?SOLR_TIMEOUT) of | ||
{ok, "200", _, _} -> ok; | ||
Err -> throw({"Failed to commit", Err}) | ||
end. | ||
|
@@ -72,7 +73,7 @@ commit(Core) -> | |
-spec core(atom(), proplist()) -> {ok, list(), binary()} | | ||
{error, term()}. | ||
core(Action, Props) -> | ||
core(Action, Props, 5000). | ||
core(Action, Props, ?SOLR_TIMEOUT). | ||
|
||
-spec core(atom(), proplist(), ms()) -> {ok, list(), binary()} | | ||
{error, term()}. | ||
|
@@ -110,7 +111,7 @@ delete(Index, Ops) -> | |
URL = ?FMT("~s/~s/update", [base_url(), Index]), | ||
Headers = [{content_type, "application/json"}], | ||
Opts = [{response_format, binary}], | ||
case ibrowse:send_req(URL, Headers, post, JSON, Opts) of | ||
case ibrowse:send_req(URL, Headers, post, JSON, Opts, ?SOLR_TIMEOUT) of | ||
{ok, "200", _, _} -> ok; | ||
Err -> {error, Err} | ||
end. | ||
|
@@ -169,7 +170,7 @@ index(Core, Docs, DelOps) -> | |
URL = ?FMT("~s/~s/update", [base_url(), Core]), | ||
Headers = [{content_type, "application/json"}], | ||
Opts = [{response_format, binary}], | ||
case ibrowse:send_req(URL, Headers, post, JSON, Opts) of | ||
case ibrowse:send_req(URL, Headers, post, JSON, Opts, ?SOLR_TIMEOUT) of | ||
{ok, "200", _, _} -> ok; | ||
Err -> throw({"Failed to index docs", Ops, Err}) | ||
end. | ||
|
@@ -197,7 +198,7 @@ partition_list(Core) -> | |
Encoded = mochiweb_util:urlencode(Params), | ||
URL = ?FMT("~s/~s/select?~s", [base_url(), Core, Encoded]), | ||
Opts = [{response_format, binary}], | ||
case ibrowse:send_req(URL, [], get, [], Opts) of | ||
case ibrowse:send_req(URL, [], get, [], Opts, ?SOLR_TIMEOUT) of | ||
{ok, "200", _, Resp} -> {ok, Resp}; | ||
Err -> {error, Err} | ||
end. | ||
|
@@ -240,7 +241,7 @@ search(Core, Headers, Params) -> | |
URL = ?FMT("~s/~s/select", [base_url(), Core]), | ||
Headers2 = [{content_type, "application/x-www-form-urlencoded"}|Headers], | ||
Opts = [{response_format, binary}], | ||
case ibrowse:send_req(URL, Headers2, post, Body, Opts) of | ||
case ibrowse:send_req(URL, Headers2, post, Body, Opts, ?SOLR_TIMEOUT) of | ||
{ok, "200", RHeaders, Resp} -> {RHeaders, Resp}; | ||
{ok, CodeStr, _, Err} -> | ||
{Code, _} = string:to_integer(CodeStr), | ||
|
@@ -320,10 +321,10 @@ encode_commit() -> | |
%% @doc Encode a delete operation into a mochijson2 compatiable term. | ||
-spec encode_delete(delete_op()) -> term(). | ||
encode_delete({key,Key}) -> | ||
Query = ?YZ_RK_FIELD_S ++ ":" ++ ibrowse_lib:url_encode(binary_to_list(Key)), | ||
Query = ?YZ_RK_FIELD_S ++ ":\"" ++ ibrowse_lib:url_encode(binary_to_list(Key)) ++ "\"", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we are breatking UTF-8 here? I don't think we have tests for indexing/searching/deleting UTF-8 keys. I'll write up a separate issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This solves the reserved word problem by using a phrase query but the more appropriate solution down the line is to use the raw or term query parsers. |
||
?QUERY(list_to_binary(Query)); | ||
encode_delete({siblings,Key}) -> | ||
Query = ?YZ_RK_FIELD_S ++ ":" ++ ibrowse_lib:url_encode(binary_to_list(Key)) ++ " AND " ++ ?YZ_VTAG_FIELD_S ++ ":[* TO *]", | ||
Query = ?YZ_RK_FIELD_S ++ ":\"" ++ ibrowse_lib:url_encode(binary_to_list(Key)) ++ "\" AND " ++ ?YZ_VTAG_FIELD_S ++ ":[* TO *]", | ||
?QUERY(list_to_binary(Query)); | ||
encode_delete({'query', Query}) -> | ||
?QUERY(Query); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are not going to index the catch-all field then set the type to
ignored
and drop the other attributes so they are inherited from the type. IMO this makes the drop semantic obvious. It also may prevent unnecessary analyzing since it uses theStrField
type (I would hopeindexed=false
prevents analysis but use a non-analyzed type just in case).