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

Configurable timeouts #1799

Merged
merged 7 commits into from
Nov 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/kibana/components/courier/fetch/fetch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function (require) {
return function fetchService(Private, es, Promise, Notifier, sessionId) {
return function fetchService(Private, es, Promise, Notifier, sessionId, configFile) {
var _ = require('lodash');
var errors = require('errors');
var moment = require('moment');
Expand Down Expand Up @@ -59,11 +59,15 @@ define(function (require) {
body = strategy.convertStatesToBody(states);

return es[strategy.clientMethod]({
timeout: configFile.shard_timeout,
preference: sessionId,
body: body
})
.then(function (resp) {
var sendResponse = function (req, resp) {
if (resp.timed_out) {
notify.warning(new errors.SearchTimeout());
}
req.complete = true;
req.resp = resp;
req.ms = req.moment.diff() * -1;
Expand Down
10 changes: 10 additions & 0 deletions src/kibana/components/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ define(function (require) {
};
inherits(errors.HastyRefresh, KbnError);

/**
* SearchTimeout error class
*/
errors.SearchTimeout = function SearchTimeout() {
KbnError.call(this,
'All or part of your request has timed out. The data shown may be incomplete.',
errors.SearchTimeout);
};
inherits(errors.SearchTimeout, KbnError);

/**
* Request Failure - When an entire mutli request fails
* @param {Error} err - the Error that came back
Expand Down
10 changes: 8 additions & 2 deletions src/kibana/plugins/discover/_segmented_fetch.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
define(function (require) {
return function DiscoverSegmentedFetch(es, Private, Promise, Notifier) {
return function DiscoverSegmentedFetch(es, Private, Promise, Notifier, configFile) {
var _ = require('lodash');
var moment = require('moment');
var searchStrategy = Private(require('components/courier/fetch/strategy/search'));
var eventName = 'segmented fetch';
var errors = require('errors');


var notify = new Notifier({
location: 'Segmented Fetch'
Expand Down Expand Up @@ -174,7 +176,8 @@ define(function (require) {
index: index,
type: state.type,
ignoreUnavailable: true,
body: state.body
body: state.body,
timeout: configFile.shard_timeout
});

this.searchPromise.abort = function () {
Expand Down Expand Up @@ -241,6 +244,9 @@ define(function (require) {

return self._executeSearch(index, state)
.then(function (resp) {
if (resp.timed_out) {
notify.warning(new errors.SearchTimeout());
}
// a response was swallowed intentionally. Try the next one
if (!resp) {
if (self.queue.length) return self._processQueue(req, state, remainingSize, loopCount);
Expand Down
1 change: 0 additions & 1 deletion src/kibana/services/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ define(function (require) {
es = esFactory({
host: configFile.elasticsearch,
log: 'info',
requestTimeout: 60000
});

return es;
Expand Down
3 changes: 3 additions & 0 deletions src/server/bin/initialize
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ ENV["RACK_ENV"] = "development" if ENV["RACK_ENV"].nil?
# Set the global_settings that are shared across every app
Kibana.global_settings[:port] = port || 5601
Kibana.global_settings[:host] = host || '0.0.0.0'
Kibana.global_settings[:request_timeout] = config["request_timeout"].nil? ? 60 : config["request_timeout"]
Kibana.global_settings[:shard_timeout] = config["shard_timeout"].nil? ? 30000 : config["shard_timeout"]

Kibana.global_settings[:config] = config
Kibana.global_settings[:elasticsearch] = elasticsearch
Kibana.global_settings[:root] = File.expand_path("#{HERE}/../")
Expand Down
10 changes: 10 additions & 0 deletions src/server/config/kibana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ kibanaIndex: ".kibana"

# The default application to laad.
defaultAppId: "discover"

# Time in seconds to wait for responses from the backend or elasticsearch.
# Note this should always be higher than "shard_timeout".
# This must be > 0
request_timeout: 60

# Time in milliseconds for elasticsearch to wait for responses from shards
# Note this should always be lower than "request_timeout".
# Set to 0 to disable (not recommended).
shard_timeout: 30000
4 changes: 4 additions & 0 deletions src/server/routes/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class Base < Sinatra::Base
config = Kibana.global_settings[:config].clone()
config['elasticsearch'] = Kibana.global_settings[:elasticsearch]
config['port'] = Kibana.global_settings[:port].to_i
config['request_timeout'] = Kibana.global_settings[:request_timeout]
config['shard_timeout'] = Kibana.global_settings[:shard_timeout]



set :root, Kibana.global_settings[:root]
set :public_folder, Kibana.global_settings[:public_folder]
Expand Down
2 changes: 2 additions & 0 deletions src/server/routes/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class Proxy < Base
# Rack middleware goes here
config = settings.config
use Rack::ReverseProxy do
reverse_proxy_options timeout: config["request_timeout"]

reverse_proxy(/^\/elasticsearch(.*)$/, "#{config["elasticsearch"]}$1")
end
end
Expand Down