Hi guys,
My company is running a logstash instance to ingest logs from customer by several input conf files, it crashed after about 1 day due to OOM, and then every time I try to start it again, it crash by OOM immediately:
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
[WARN ] 2019-05-03 01:30:29.110 [LogStash::Runner] multilocal - Ignoring the 'pipelines.yml' file because modules or command line options are specified
[INFO ] 2019-05-03 01:30:29.645 [LogStash::Runner] runner - Starting Logstash {"logstash.version"=>"6.3.2"}
java.lang.OutOfMemoryError: Java heap space
Dumping heap to java_pid29256.hprof ...
Heap dump file created [142110250 bytes in 0.812 secs]
[ERROR] 2019-05-03 01:30:31.433 [LogStash::Runner] Logstash - java.lang.OutOfMemoryError: Java heap space
This is strange because I have the jvm setting as -Xms1g and -Xmx1g, but the memory dump is only 142 MB, and after I increase java heap to 2g, it's still the same. Then I increased java heap to 4g, it didn't get OOM but throwing the following error messages all the time:
[ERROR] 2019-05-02 01:09:35.262 [Ruby-0-Thread-1: /usr/share/logstash/lib/bootstrap/environment.rb:6] sourceloader - Could not fetch all the sources {:exception=>Java::JavaLang::NegativeArraySizeException, :message=>"", :backtrace=>["org.jruby.util.ByteList.ensure(ByteList.java:341)", "org.jruby.RubyString.modify(RubyString.java:950)", "org.jruby.RubyString.modifyExpand(RubyString.java:960)", "org.jruby.util.io.EncodingUtils.setStrBuf(EncodingUtils.java:1117)", "org.jruby.util.io.OpenFile.fread(OpenFile.java:1755)", "org.jruby.util.io.OpenFile.readAll(OpenFile.java:1669)", "org.jruby.RubyIO.read(RubyIO.java:3009)", "org.jruby.RubyIO.read(RubyIO.java:2993)", "org.jruby.RubyIO.read19(RubyIO.java:3607)", "usr.share.logstash.logstash_minus_core.lib.logstash.config.source.local.RUBY$block$read$1(/usr/share/logstash/logstash-core/lib/logstash/config/source/local.rb:73)", "org.jruby.runtime.CompiledIRBlockBody.yieldDirect(CompiledIRBlockBody.java:156)", "org.jruby.runtime.BlockBody.yield(BlockBody.java:114)", "org.jruby.runtime.Block.yield(Block.java:165)", "org.jruby.RubyArray.each(RubyArray.java:1734)", "usr.share.logstash.logstash_minus_core.lib.logstash.config.source.local.RUBY$method$read$0(/usr/share/logstash/logstash-core/lib/logstash/config/source/local.rb:63)", "usr.share.logstash.logstash_minus_core.lib.logstash.config.source.local.RUBY$method$read$0(/usr/share/logstash/logstash-core/lib/logstash/config/source/local.rb:96)", "usr.share.logstash.logstash_minus_core.lib.logstash.config.source.local.RUBY$method$local_pipeline_configs$0(/usr/share/logstash/logstash-core/lib/logstash/config/source/local.rb:192)", "usr.share.logstash.logstash_minus_core.lib.logstash.config.source.local.RUBY$method$pipeline_configs$0(/usr/share/logstash/logstash-core/lib/logstash/config/source/local.rb:163)", "usr.share.logstash.logstash_minus_core.lib.logstash.config.source_loader.RUBY$block$fetch$3(/usr/share/logstash/logstash-core/lib/logstash/config/source_loader.rb:62)", "org.jruby.runtime.CompiledIRBlockBody.yieldDirect(CompiledIRBlockBody.java:156)", "org.jruby.runtime.BlockBody.yield(BlockBody.java:114)", "org.jruby.runtime.Block.yield(Block.java:165)", "org.jruby.RubyArray.collect(RubyArray.java:2472)", "org.jruby.RubyArray.collect19(RubyArray.java:2481)", "usr.share.logstash.logstash_minus_core.lib.logstash.config.source_loader.RUBY$method$fetch$0(/usr/share/logstash/logstash-core/lib/logstash/config/source_loader.rb:61)", "usr.share.logstash.logstash_minus_core.lib.logstash.agent.RUBY$method$converge_state_and_update$0(/usr/share/logstash/logstash-core/lib/logstash/agent.rb:138)", "usr.share.logstash.logstash_minus_core.lib.logstash.agent.RUBY$block$execute$1(/usr/share/logstash/logstash-core/lib/logstash/agent.rb:106)", "org.jruby.runtime.CompiledIRBlockBody.callDirect(CompiledIRBlockBody.java:145)", "org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:71)", "org.jruby.runtime.Block.call(Block.java:124)", "org.jruby.RubyProc.call(RubyProc.java:289)", "org.jruby.RubyProc.call19(RubyProc.java:273)", "usr.share.logstash.vendor.bundle.jruby.$2_dot_3_dot_0.gems.stud_minus_0_dot_0_dot_23.lib.stud.interval.RUBY$method$interval$0(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/interval.rb:18)", "org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:77)", "org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:93)", "org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:145)", "usr.share.logstash.logstash_minus_core.lib.logstash.agent.RUBY$method$execute$0(/usr/share/logstash/logstash-core/lib/logstash/agent.rb:95)", "usr.share.logstash.logstash_minus_core.lib.logstash.agent.RUBY$method$execute$0$VARARGS(/usr/share/logstash/logstash-core/lib/logstash/agent.rb)", "org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:77)", "org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:93)", "org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:145)", "usr.share.logstash.logstash_minus_core.lib.logstash.runner.RUBY$block$execute$5(/usr/share/logstash/logstash-core/lib/logstash/runner.rb:363)", "org.jruby.runtime.CompiledIRBlockBody.callDirect(CompiledIRBlockBody.java:145)", "org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:71)", "org.jruby.runtime.Block.call(Block.java:124)", "org.jruby.RubyProc.call(RubyProc.java:289)", "org.jruby.RubyProc.call19(RubyProc.java:273), "org.jruby.RubyProc$INVOKER$i$0$0$cal
l19.call(RubyProc$INVOKER$i$0$0$call19.gen)", "org.jruby.ir.targets.InvokeSite.invoke(InvokeSite.java:145)", "usr.share.logstash.vendor.bundle.jruby.$2_dot_3_dot_0.gems.stud_minus_0_dot_0_dot_23.lib.stud.task.RUBY$block$initialize$1(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24)", "org.jruby.runtime.CompiledIRBlockBody.callDirect(CompiledIRBlockBody.java:145)", "org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:71)", "org.jruby.runtime.Block.call(Block.java:124)", "org.jruby.RubyProc.call(RubyProc.java:289)", "org.jruby.RubyProc.call(RubyProc.java:246)", "org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:104)", "java.lang.Thread.run(Thread.java:748)"]}
We are running logstash by:
sudo nohup /usr/share/logstash/bin/logstash -f ./logstash/conf/ -w 3 --config.reload.automatic > /var/log/logstash/logstash1.log &
There are 4 conf files in the ./logstash/conf/ directory
And logstash version is 6.3.2
I did some search on web but still cannot figure out what happened. Also looked at the 142M memory dump through VisualVM, didn't find any dominating object, all objects look fine. Please help and thanks in advance!