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

Timeout while fetching cluster config #88

Closed
nitinstp23 opened this issue Jul 19, 2020 · 2 comments · Fixed by #89
Closed

Timeout while fetching cluster config #88

nitinstp23 opened this issue Jul 19, 2020 · 2 comments · Fixed by #89

Comments

@nitinstp23
Copy link
Contributor

exit: ** (exit) exited in: GenServer.call(MyApp.ElasticsearchCluster, :config, 5000)
    ** (EXIT) time out
  File "lib/gen_server.ex", line 836, in GenServer.call/3
  File "lib/elasticsearch.ex", line 307, in Elasticsearch.post/4

We get this error randomly in our app while making GET/POST requests to Elasticsearch.

Elasticsearch.post/4 calls Elasticsearch .Cluster.Config.get(cluster) here

And the cluster config is found via this - https://github.com/danielberkompas/elasticsearch-elixir/blob/master/lib/elasticsearch/cluster/cluster.ex#L172

Given the cluster is a GenServer and this call GenServer.call/3 can timeout since a single process can get overloaded under heavy load.

Can we move the :api out of the cluster config and the user can pass the Elasticsearch.API behaviour module to functions like Elasticsearch.get, Elasticsearch.post, etc?

@danielberkompas Let me know your thoughts.

@danielberkompas
Copy link
Owner

It does seem like cutting out the GenServer.call would be beneficial here. My encryption library Cloak handles this by saving the config to an ETS table and then reading it out of the ETS table in a function, rather than via GenServer. Perhaps this could serve as a pattern to fix the issue?

https://github.com/danielberkompas/cloak/blob/master/lib/cloak/vault.ex#L274-L292

@nitinstp23
Copy link
Contributor Author

@danielberkompas Yes, saving the config in an ETS table will definitely help here. I'll try to send a PR soon!

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