Prevent SSL HandshakeCompletionNotify_Thread from burning CPU time?Create ArrayList from arrayHow do I call one constructor from another in Java?How to get an enum value from a string value in Java?How do I update the GUI from another thread?Why is subtracting these two times (in 1927) giving a strange result?Glassfish grizzly thread consuming 100% CPU timeGlassfish 4 Grizzly Threads Heavy CPU usageThread caught burning CPU when raytracing in parallel with GCDJava web application using 100% of single CPU coreScheduledThreadPoolExecutor with corePoolSize = 0 causes 100% load on one CPU core

All of my Firefox add-ons been disabled suddenly, how can I re-enable them?

Is there a reason why Turkey took the Balkan territories of the Ottoman Empire, instead of Greece or another of the Balkan states?

Can a good but unremarkable PhD student become an accomplished professor?

Subnumcases as a part of align

HSA - Continue to Invest?

Picking a theme as a discovery writer

How would you say "You forget wearing what you're wearing"?

Referring to person by surname, keep or omit "von"?

Can an Iranian citizen enter the USA on a Dutch passport?

Huffman Code in C++

GitLab account hacked and repo wiped

Game artist computer workstation set-up – is this overkill?

What would happen if I combined this polymer and this metal (assuming I can)

What is more safe for browsing the web: PC or smartphone?

Why doesn't a particle exert force on itself?

TIP120 Transistor + Solenoid Failing Randomly

How to preserve a rare version of a book?

How important are good looking people in a novel/story?

How did the Apollo guidance computer handle parity bit errors?

Installing Debian 10, upgrade to stable later?

Gerrymandering Puzzle - Rig the Election

Is it normal for gliders not to have attitude indicators?

Can I combine SELECT TOP() with the IN operator?

What does the copyright in a dissertation protect exactly?



Prevent SSL HandshakeCompletionNotify_Thread from burning CPU time?


Create ArrayList from arrayHow do I call one constructor from another in Java?How to get an enum value from a string value in Java?How do I update the GUI from another thread?Why is subtracting these two times (in 1927) giving a strange result?Glassfish grizzly thread consuming 100% CPU timeGlassfish 4 Grizzly Threads Heavy CPU usageThread caught burning CPU when raytracing in parallel with GCDJava web application using 100% of single CPU coreScheduledThreadPoolExecutor with corePoolSize = 0 causes 100% load on one CPU core






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Problem



A Glassfish instance with 60 webapps (.war's) installed occasionally burns 100-150% of a CPU core or more for many minutes while there is no significant workload to justify it.



Sometimes it gets so bad that applications stop responding and the instance will not shut down in reasonable time (> 1 hour) without a kill -9.



Environment



  • Linux (CentOS) 4 core, physical hardware.


  • Java 1.8u65, Oracle, Hotspot


  • Glassfish 4.1.1 - About 60 WebApps (war files) installed.


  • JMX reports plenty of free heap (arund 50%). Linux reports insignificant memory pressure.


  • Nonessential GF tasks such as autodeploy, autorefresh, updater, are disabled.


Investigation



I can reproduce the problem on an idle system with la <= 0.3 by navigating to the Applications view in Glassfish html admin console after a fresh restart of GF with all applications except admin console disabled.



Navigating to the Applications view causes GF to open 195 loopback ssl connections. The GF admin gui source code shows that their jsf layer will make >1 https request to the GF instance (itself) for each app installed.



Using top/htop and JVM thread dumps I found that the threads with runaway cpu use were all named HandshakeCompletionNotify_Thread, and created by javax.net.SSLSocketImpl.



Many HandshakeCompletionNotify threads (>40) were hanging around and a few of them (1 to 4 on a four core instance) were always using 40% to 100% of a cpu core.



What does the code say?



The OpenJDK SSLSocketImpl source suggests that the HandshakeCompletionNotify_Thread really does not have much to do. It normally completes very quickly and ends the thread. Here's the run method from OpenJDK's JDK 8 to show the concept.



@Override
public void run()
// Don't need to synchronize, as it only runs in one thread.
for (Map.Entry<HandshakeCompletedListener,AccessControlContext>
entry : targets)

final HandshakeCompletedListener l = entry.getKey();
AccessControlContext acc = entry.getValue();
AccessController.doPrivileged(new PrivilegedAction<Void>()
@Override
public Void run()
l.handshakeCompleted(event);
return null;

, acc);




  • We don't use a security manager, so doPrivileged should not be able to delay it significantly.


  • targets is a HashSet<>, so no synchronization.


  • Implementations of HandshakeCompletedListener that I have found don't seem to have any reason to block on the handshakeCompleted() method.


The HandshakeCompletionNotify_Threads appear in the thread dump in Runnable state with no stack trace. Not sure what this means. Were these threads not responding to signals? (speculation) Had they not yet called the run() method? The JDK documentation warns that some JVM's may leave frames out of stack traces. Would that explain it?



Question



  1. Why would these HandshakeCompletionNotify_Threads pile up and burn cpu time?


  2. How can I prevent it from happening?


Hunches (nothing solid)



  • We're actually waiting for thread creation and initialization. Something is jammed there.


  • They are burning time in a system call that I can't see, maybe allocating or mapping memory.


  • We missed some configuration for ssl, dns, something.


Why do I care?
I did the investigation to find out if my team's software had introduced something too risky to release into production environments. Now I am sure our software does not have to be present to produce the problem.



Now the problem just bugs me and I don't want to have trouble with it at scale. There were a couple of JDK bugs reported on JDK 1.6 related to these completion notify threads, but they are logged as fixed in JDK 7 and 8. Maybe there is a remaining aspect of the JDK bug. Maybe Glassfish or Grizzly has a badly implemented HandShakeCompletionListener.










share|improve this question






























    0















    Problem



    A Glassfish instance with 60 webapps (.war's) installed occasionally burns 100-150% of a CPU core or more for many minutes while there is no significant workload to justify it.



    Sometimes it gets so bad that applications stop responding and the instance will not shut down in reasonable time (> 1 hour) without a kill -9.



    Environment



    • Linux (CentOS) 4 core, physical hardware.


    • Java 1.8u65, Oracle, Hotspot


    • Glassfish 4.1.1 - About 60 WebApps (war files) installed.


    • JMX reports plenty of free heap (arund 50%). Linux reports insignificant memory pressure.


    • Nonessential GF tasks such as autodeploy, autorefresh, updater, are disabled.


    Investigation



    I can reproduce the problem on an idle system with la <= 0.3 by navigating to the Applications view in Glassfish html admin console after a fresh restart of GF with all applications except admin console disabled.



    Navigating to the Applications view causes GF to open 195 loopback ssl connections. The GF admin gui source code shows that their jsf layer will make >1 https request to the GF instance (itself) for each app installed.



    Using top/htop and JVM thread dumps I found that the threads with runaway cpu use were all named HandshakeCompletionNotify_Thread, and created by javax.net.SSLSocketImpl.



    Many HandshakeCompletionNotify threads (>40) were hanging around and a few of them (1 to 4 on a four core instance) were always using 40% to 100% of a cpu core.



    What does the code say?



    The OpenJDK SSLSocketImpl source suggests that the HandshakeCompletionNotify_Thread really does not have much to do. It normally completes very quickly and ends the thread. Here's the run method from OpenJDK's JDK 8 to show the concept.



    @Override
    public void run()
    // Don't need to synchronize, as it only runs in one thread.
    for (Map.Entry<HandshakeCompletedListener,AccessControlContext>
    entry : targets)

    final HandshakeCompletedListener l = entry.getKey();
    AccessControlContext acc = entry.getValue();
    AccessController.doPrivileged(new PrivilegedAction<Void>()
    @Override
    public Void run()
    l.handshakeCompleted(event);
    return null;

    , acc);




    • We don't use a security manager, so doPrivileged should not be able to delay it significantly.


    • targets is a HashSet<>, so no synchronization.


    • Implementations of HandshakeCompletedListener that I have found don't seem to have any reason to block on the handshakeCompleted() method.


    The HandshakeCompletionNotify_Threads appear in the thread dump in Runnable state with no stack trace. Not sure what this means. Were these threads not responding to signals? (speculation) Had they not yet called the run() method? The JDK documentation warns that some JVM's may leave frames out of stack traces. Would that explain it?



    Question



    1. Why would these HandshakeCompletionNotify_Threads pile up and burn cpu time?


    2. How can I prevent it from happening?


    Hunches (nothing solid)



    • We're actually waiting for thread creation and initialization. Something is jammed there.


    • They are burning time in a system call that I can't see, maybe allocating or mapping memory.


    • We missed some configuration for ssl, dns, something.


    Why do I care?
    I did the investigation to find out if my team's software had introduced something too risky to release into production environments. Now I am sure our software does not have to be present to produce the problem.



    Now the problem just bugs me and I don't want to have trouble with it at scale. There were a couple of JDK bugs reported on JDK 1.6 related to these completion notify threads, but they are logged as fixed in JDK 7 and 8. Maybe there is a remaining aspect of the JDK bug. Maybe Glassfish or Grizzly has a badly implemented HandShakeCompletionListener.










    share|improve this question


























      0












      0








      0








      Problem



      A Glassfish instance with 60 webapps (.war's) installed occasionally burns 100-150% of a CPU core or more for many minutes while there is no significant workload to justify it.



      Sometimes it gets so bad that applications stop responding and the instance will not shut down in reasonable time (> 1 hour) without a kill -9.



      Environment



      • Linux (CentOS) 4 core, physical hardware.


      • Java 1.8u65, Oracle, Hotspot


      • Glassfish 4.1.1 - About 60 WebApps (war files) installed.


      • JMX reports plenty of free heap (arund 50%). Linux reports insignificant memory pressure.


      • Nonessential GF tasks such as autodeploy, autorefresh, updater, are disabled.


      Investigation



      I can reproduce the problem on an idle system with la <= 0.3 by navigating to the Applications view in Glassfish html admin console after a fresh restart of GF with all applications except admin console disabled.



      Navigating to the Applications view causes GF to open 195 loopback ssl connections. The GF admin gui source code shows that their jsf layer will make >1 https request to the GF instance (itself) for each app installed.



      Using top/htop and JVM thread dumps I found that the threads with runaway cpu use were all named HandshakeCompletionNotify_Thread, and created by javax.net.SSLSocketImpl.



      Many HandshakeCompletionNotify threads (>40) were hanging around and a few of them (1 to 4 on a four core instance) were always using 40% to 100% of a cpu core.



      What does the code say?



      The OpenJDK SSLSocketImpl source suggests that the HandshakeCompletionNotify_Thread really does not have much to do. It normally completes very quickly and ends the thread. Here's the run method from OpenJDK's JDK 8 to show the concept.



      @Override
      public void run()
      // Don't need to synchronize, as it only runs in one thread.
      for (Map.Entry<HandshakeCompletedListener,AccessControlContext>
      entry : targets)

      final HandshakeCompletedListener l = entry.getKey();
      AccessControlContext acc = entry.getValue();
      AccessController.doPrivileged(new PrivilegedAction<Void>()
      @Override
      public Void run()
      l.handshakeCompleted(event);
      return null;

      , acc);




      • We don't use a security manager, so doPrivileged should not be able to delay it significantly.


      • targets is a HashSet<>, so no synchronization.


      • Implementations of HandshakeCompletedListener that I have found don't seem to have any reason to block on the handshakeCompleted() method.


      The HandshakeCompletionNotify_Threads appear in the thread dump in Runnable state with no stack trace. Not sure what this means. Were these threads not responding to signals? (speculation) Had they not yet called the run() method? The JDK documentation warns that some JVM's may leave frames out of stack traces. Would that explain it?



      Question



      1. Why would these HandshakeCompletionNotify_Threads pile up and burn cpu time?


      2. How can I prevent it from happening?


      Hunches (nothing solid)



      • We're actually waiting for thread creation and initialization. Something is jammed there.


      • They are burning time in a system call that I can't see, maybe allocating or mapping memory.


      • We missed some configuration for ssl, dns, something.


      Why do I care?
      I did the investigation to find out if my team's software had introduced something too risky to release into production environments. Now I am sure our software does not have to be present to produce the problem.



      Now the problem just bugs me and I don't want to have trouble with it at scale. There were a couple of JDK bugs reported on JDK 1.6 related to these completion notify threads, but they are logged as fixed in JDK 7 and 8. Maybe there is a remaining aspect of the JDK bug. Maybe Glassfish or Grizzly has a badly implemented HandShakeCompletionListener.










      share|improve this question
















      Problem



      A Glassfish instance with 60 webapps (.war's) installed occasionally burns 100-150% of a CPU core or more for many minutes while there is no significant workload to justify it.



      Sometimes it gets so bad that applications stop responding and the instance will not shut down in reasonable time (> 1 hour) without a kill -9.



      Environment



      • Linux (CentOS) 4 core, physical hardware.


      • Java 1.8u65, Oracle, Hotspot


      • Glassfish 4.1.1 - About 60 WebApps (war files) installed.


      • JMX reports plenty of free heap (arund 50%). Linux reports insignificant memory pressure.


      • Nonessential GF tasks such as autodeploy, autorefresh, updater, are disabled.


      Investigation



      I can reproduce the problem on an idle system with la <= 0.3 by navigating to the Applications view in Glassfish html admin console after a fresh restart of GF with all applications except admin console disabled.



      Navigating to the Applications view causes GF to open 195 loopback ssl connections. The GF admin gui source code shows that their jsf layer will make >1 https request to the GF instance (itself) for each app installed.



      Using top/htop and JVM thread dumps I found that the threads with runaway cpu use were all named HandshakeCompletionNotify_Thread, and created by javax.net.SSLSocketImpl.



      Many HandshakeCompletionNotify threads (>40) were hanging around and a few of them (1 to 4 on a four core instance) were always using 40% to 100% of a cpu core.



      What does the code say?



      The OpenJDK SSLSocketImpl source suggests that the HandshakeCompletionNotify_Thread really does not have much to do. It normally completes very quickly and ends the thread. Here's the run method from OpenJDK's JDK 8 to show the concept.



      @Override
      public void run()
      // Don't need to synchronize, as it only runs in one thread.
      for (Map.Entry<HandshakeCompletedListener,AccessControlContext>
      entry : targets)

      final HandshakeCompletedListener l = entry.getKey();
      AccessControlContext acc = entry.getValue();
      AccessController.doPrivileged(new PrivilegedAction<Void>()
      @Override
      public Void run()
      l.handshakeCompleted(event);
      return null;

      , acc);




      • We don't use a security manager, so doPrivileged should not be able to delay it significantly.


      • targets is a HashSet<>, so no synchronization.


      • Implementations of HandshakeCompletedListener that I have found don't seem to have any reason to block on the handshakeCompleted() method.


      The HandshakeCompletionNotify_Threads appear in the thread dump in Runnable state with no stack trace. Not sure what this means. Were these threads not responding to signals? (speculation) Had they not yet called the run() method? The JDK documentation warns that some JVM's may leave frames out of stack traces. Would that explain it?



      Question



      1. Why would these HandshakeCompletionNotify_Threads pile up and burn cpu time?


      2. How can I prevent it from happening?


      Hunches (nothing solid)



      • We're actually waiting for thread creation and initialization. Something is jammed there.


      • They are burning time in a system call that I can't see, maybe allocating or mapping memory.


      • We missed some configuration for ssl, dns, something.


      Why do I care?
      I did the investigation to find out if my team's software had introduced something too risky to release into production environments. Now I am sure our software does not have to be present to produce the problem.



      Now the problem just bugs me and I don't want to have trouble with it at scale. There were a couple of JDK bugs reported on JDK 1.6 related to these completion notify threads, but they are logged as fixed in JDK 7 and 8. Maybe there is a remaining aspect of the JDK bug. Maybe Glassfish or Grizzly has a badly implemented HandShakeCompletionListener.







      java multithreading ssl glassfish






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 23 at 5:54







      joshp

















      asked Mar 23 at 4:01









      joshpjoshp

      1,67221526




      1,67221526






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55310504%2fprevent-ssl-handshakecompletionnotify-thread-from-burning-cpu-time%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55310504%2fprevent-ssl-handshakecompletionnotify-thread-from-burning-cpu-time%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현