-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Running Count
on a newly created index throws an exception with "Could not parse server exception"
#1596
Comments
I should note that this also throws an error: while (true)
{
client.CreateIndex(indexName);
client.SyncedFlush(d => d.Index(indexName));
client.DeleteIndex(indexName);
} Stacktrace:
|
Response:
The
I don't know enough Elasticsearch to know why the server returns 503, or why the Hopefully this will be enough so some experts might find the correct fix for this issue. |
Setting a |
Somewhat related: 503 errors doesn't get a good error message. The following patch manually sets the error fields. diff --git a/src/Elasticsearch.Net/Connection/RequestHandlers/RequestHandler.cs b/src/Elasticsearch.Net/Connection/RequestHandlers/RequestHandler.cs
index 7ad8abc..cb993f9 100644
--- a/src/Elasticsearch.Net/Connection/RequestHandlers/RequestHandler.cs
+++ b/src/Elasticsearch.Net/Connection/RequestHandlers/RequestHandler.cs
@@ -106,7 +106,7 @@ namespace Elasticsearch.Net.Connection.RequestHandlers
return this.StreamToTypedResponse<T>(streamResponse, requestState, bytes);
// If error read error
- error = GetErrorFromStream<T>(streamResponse.Response);
+ error = GetErrorFromStream<T>(streamResponse.Response, streamResponse.HttpStatusCode ?? 0);
var typedResponse = ElasticsearchResponse.CloneFrom<T>(streamResponse, default(T));
this.SetStringOrByteResult(typedResponse, bytes);
return typedResponse;
diff --git a/src/Elasticsearch.Net/Connection/RequestHandlers/RequestHandlerBase.cs b/src/Elasticsearch.Net/Connection/RequestHandlers/RequestHandlerBase.cs
index 49f471c..ce8c0b6 100644
--- a/src/Elasticsearch.Net/Connection/RequestHandlers/RequestHandlerBase.cs
+++ b/src/Elasticsearch.Net/Connection/RequestHandlers/RequestHandlerBase.cs
@@ -211,11 +211,17 @@ namespace Elasticsearch.Net.Connection.RequestHandlers
response.Response = rawResponse;
}
- protected ElasticsearchServerError GetErrorFromStream<T>(Stream stream)
+ protected ElasticsearchServerError GetErrorFromStream<T>(Stream stream, int httpStatusCode=0)
{
try
{
var e = this._serializer.Deserialize<OneToOneServerException>(stream);
+ if (e != null && e.status == 0)
+ {
+ e.status = httpStatusCode;
+ if (e.status == 503 && e.error.IsNullOrEmpty())
+ e.error = "ServiceUnavailableException[Service Unavaliable. Try again later.]";
+ }
return ElasticsearchServerError.Create(e);
}
// ReSharper disable once EmptyGeneralCatchClause
|
Service Unavailable can happen before shards are updates (creating a new index, and then query it before it's created). These errors are not reported as regular errors, and receives a very generic errormessage. This commit improves the error message for these errors. Closes elastic#1596
Service Unavailable can happen before shards are updates (creating a new index, and then query it before it's created). These errors are not reported as regular errors, and receives a very generic errormessage. This commit improves the error message for these errors. Closes elastic#1596
Service Unavailable can happen before shards are updates (creating a new index, and then query it before it's created). These errors are not reported as regular errors, and receives a very generic errormessage. This commit improves the error message for these errors. Closes elastic#1596
Your hunch is correct. The The way it solved right now is to wait for at least a yellow status on the cluster after index creation. Elasticsearch 2.0 has a lot saner exception output just as an FYI :) Thanks for the PR will review it monday morning. |
Closing this issue because we merged the service unavailable improvements but the underlying cause is elastic/elasticsearch#9126 |
Quite hard to find a reliable way of reproducing the error, but the following works every time for me:
Stacktrace:
This has been reproduced in Elasticsearch 1.7.2 and 1.7.3, but I've only tested Elasticsearch.Net 1.7.1.
The text was updated successfully, but these errors were encountered: