在连续上传时获取elasticsearch连接错误

时间:2012-10-09 09:32:49

标签: ruby elasticsearch tire

我有一个脚本,它从csv文件中逐个读取行,并以相同的顺序将其索引到elasticsearch。我的elasticsearch主机与运行脚本的机器相同。当我突然开始出现以下错误时,除了几行之外,其他所有工作正常:

W, [2012-10-09T14:46:00.899876 #11567]  WARN -- : Cannot assign requested address connect(2)
D, [2012-10-09T14:46:00.900037 #11567] DEBUG -- : ["/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in `initialize'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in `open'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in `block in connect'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/timeout.rb:44:in `timeout'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/timeout.rb:89:in `timeout'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in `connect'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:637:in `do_start'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:626:in `start'", "/home/azitabh/.rvm/gems/ruby-1.9.2-p320/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'", "/home/azitabh/.rvm/gems/ruby-1.9.2-p320/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'", "/home/azitabh/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/http/client.rb:11:in `get'", "/home/azitabh/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/search.rb:94:in `perform'", "/home/azitabh/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/search.rb:20:in `results'", "models/test.rb:31:in `get_details'", "models/test.rb:56:in `block in index_test'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/csv.rb:1768:in `each'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/csv.rb:1202:in `block in foreach'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/csv.rb:1340:in `open'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/csv.rb:1201:in `foreach'", "models/test.rb:40:in `index_test'", "models/test.rb:85:in `<main>'"]

错误与csv中这些行的值无关。我在不同的时间在不同的位置得到这些错误。

还有一个错误“WAIT_TIMEOUT”我得到了一些时间。无法将跟踪放在这里,因为我这次没有收到错误。

我在ruby编码并使用“Tire”gem与elasticsearch交谈。我不认为这些是以任何方式负责的。

当我收到此错误时,JAVA使用了系统内存的8%。这远低于指定值ES_MIN_MEM = 2g。

提前致谢 -Azitabh

1 个答案:

答案 0 :(得分:1)

这种情况正在发生,因为轮胎本身并未关闭tcp连接。一旦所有可用端口都被使用,在系统关闭处于等待状态的所有连接之前,不可能进一步连接。这需要一些时间,并且任何尝试建立新连接都会导致wait_timeout。