Uploaded image for project: 'WildFly Core'
  1. WildFly Core
  2. WFCORE-1218

Connecting to controller via new CommandContext instance leak threads

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 2.0.5.CR1
    • None
    • CLI
    • None
    • Hide
      cd $JBOSS_HOME/bin
      ./standalone.sh &
      JAR=$JBOSS_HOME/bin/client/jboss-cli-client.jar
      javac -cp $JAR Demo.java ; java -cp .:$JAR Demo
      
      ###########   ACTIVE THREADS COUNT   ###########
      #    1  (+1)
      Wait before the test, attach VisualVM or other monitoring tool here.
      Press "enter" to continue . . . 
      ...
      Exception in thread "main" java.lang.IllegalStateException: Unable to initialize command context.
      	at org.jboss.as.cli.scriptsupport.CLI.connect(CLI.java:83)
      	at Demo.main(Demo.java:40)
      Caused by: org.jboss.as.cli.CliInitializationException: Failed to initialize Aesh console
      	at org.jboss.as.cli.impl.Console$Factory.getConsole(Console.java:121)
      	at org.jboss.as.cli.impl.Console$Factory.getConsole(Console.java:112)
      	at org.jboss.as.cli.impl.CommandContextImpl.initBasicConsole(CommandContextImpl.java:389)
      	at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:987)
      	at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:980)
      	at org.jboss.as.cli.scriptsupport.CLI.connect(CLI.java:81)
      	... 1 more
      Caused by: java.lang.OutOfMemoryError: unable to create new native thread
      	at java.lang.Thread.start0(Native Method)
      	at java.lang.Thread.start(Thread.java:714)
      	at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)
      	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1357)
      	at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:668)
      	at org.jboss.aesh.console.reader.ConsoleInputSession.startReader(ConsoleInputSession.java:83)
      	at org.jboss.aesh.console.reader.ConsoleInputSession.<init>(ConsoleInputSession.java:60)
      	at org.jboss.aesh.terminal.POSIXTerminal.init(POSIXTerminal.java:105)
      	at org.jboss.aesh.console.Console.init(Console.java:188)
      	at org.jboss.aesh.console.Console.<init>(Console.java:118)
      	at org.jboss.as.cli.impl.Console$Factory.getConsole(Console.java:119)
      	... 6 more
      
      Show
      cd $JBOSS_HOME/bin ./standalone.sh & JAR=$JBOSS_HOME/bin/client/jboss-cli-client.jar javac -cp $JAR Demo.java ; java -cp .:$JAR Demo ########### ACTIVE THREADS COUNT ########### # 1 (+1) Wait before the test, attach VisualVM or other monitoring tool here. Press "enter" to continue . . . ... Exception in thread "main" java.lang.IllegalStateException: Unable to initialize command context. at org.jboss.as.cli.scriptsupport.CLI.connect(CLI.java:83) at Demo.main(Demo.java:40) Caused by: org.jboss.as.cli.CliInitializationException: Failed to initialize Aesh console at org.jboss.as.cli.impl.Console$Factory.getConsole(Console.java:121) at org.jboss.as.cli.impl.Console$Factory.getConsole(Console.java:112) at org.jboss.as.cli.impl.CommandContextImpl.initBasicConsole(CommandContextImpl.java:389) at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:987) at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:980) at org.jboss.as.cli.scriptsupport.CLI.connect(CLI.java:81) ... 1 more Caused by: java.lang.OutOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:714) at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1357) at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:668) at org.jboss.aesh.console.reader.ConsoleInputSession.startReader(ConsoleInputSession.java:83) at org.jboss.aesh.console.reader.ConsoleInputSession.<init>(ConsoleInputSession.java:60) at org.jboss.aesh.terminal.POSIXTerminal.init(POSIXTerminal.java:105) at org.jboss.aesh.console.Console.init(Console.java:188) at org.jboss.aesh.console.Console.<init>(Console.java:118) at org.jboss.as.cli.impl.Console$Factory.getConsole(Console.java:119) ... 6 more

      Connecting to a controller via a new CommandContext always init a new console which could lead into "OutOfMemoryError: unable to create new native thread" as initBasicConsole() creates a pair of Aesh thread which are not cleaned up with terminateSession().

      import org.jboss.as.cli.scriptsupport.CLI;
      
      CLI cli = CLI.newInstance();
      for (int i = 1; i <= tries; i++) {
                  cli.connect();
                  cli.disconnect();
      }
      

      Reproducer waits for 10s after every 50 connections, that's where the steps on the graph comes from:

      Regression against 7.0.0.ER1 and 6.4.x

              olubyans@redhat.com Alexey Loubyansky
              olubyans@redhat.com Alexey Loubyansky
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: