Skip to content
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

Reopen the connection on timeout #100

Closed
TwP opened this issue Jul 2, 2015 · 2 comments
Closed

Reopen the connection on timeout #100

TwP opened this issue Jul 2, 2015 · 2 comments

Comments

@TwP
Copy link
Contributor

TwP commented Jul 2, 2015

When the read_timeout is reached in Elastomer::Client, an exception is raised and the Ruby code aborts the request handling process. The Elasticsearch cluster will continue processing the search request and will eventually send a response - the HTTP connection is still open. Subsequent calls using this same connection can return search results for a previous request that timed out. This scenario is the reason that the OpaqueId middleware exists.

A more proactive solution would be to not reuse the connection when a read timeout is reached. Instead, the connection should be discarded and a new connection established. This will prevent subsequent search requests from triggering the OpaqueId error condition.

/cc @grantr @tmm1

@TwP
Copy link
Contributor Author

TwP commented Jul 2, 2015

After doing a little more digging, I think the read timeout theory is a red herring. In production we are using a persistent Excon adapter. Excon will close the current socket if it reaches a read timeout or a write timeout. Because of this, we will never get an OpaqueId error because an HTTP connection is reused after a timeout.

The root cause of the OpaqueId errors is due to something else.

@TwP TwP closed this as completed Jul 2, 2015
@grantr
Copy link
Contributor

grantr commented Jul 6, 2015

The original purpose of the OpaqueId middleware was to work around a (now fixed) bug in excon that didn't reset the connection properly. We still see OpaqueId errors occasionally, so there's something else in the stack that can cause the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants