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

The warning message "AS-CONCURRENT-00001" is written to server.log many times. #8

Open
glassfishrobot opened this issue Oct 14, 2016 · 4 comments

Comments

@glassfishrobot
Copy link

User application submits a task to ManagedExecutorService or ManagedScheduledExecutorService.
Once the task processing time exceeds the "hung-after-seconds" value of ManagedExecutorService or ManagedScheduledExecutorService, a warning message "AS-CONCURRENT-00001" is written to server.log file repeatedly every minute until the task finishes.

When a lot of tasks do hang, a large amount of same "AS-CONCURRENT-00001" messages are written to server.log file.
In that case, there is a risk that other important messages are missed or lost by rotating the server.log file.

Therefore, I hope to change behavior so that the "AS-CONCURRENT-00001" message is written only once for each task when the task processing time exceeds the "hung-after-seconds".

I also hope to maintain compatibility by adding an additional property to ManagedExecutorService and ManagedScheduledExecutorService, so user can specify the behavior when the task processing time exceeds the "hung-after-seconds".

The "hung-after-seconds" value of ManagedExecutorService can be specified by the command below:

asadmin set resources.managed-executor-service.<jndi-name>.hung-after-seconds

This issue is related to glassfish issue https://java.net/jira/browse/GLASSFISH-21561

Environment

Glassfish 4.1

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Reported by uno_kohei

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
uno_kohei said:
I propose a patch for fixing this bug.
See also the patch for GLASSFISH-21561

Index: src/main/java/org/glassfish/enterprise/concurrent/AbstractManagedExecutorService.java
===================================================================
--- src/main/java/org/glassfish/enterprise/concurrent/AbstractManagedExecutorService.java	(Revision 72)
+++ src/main/java/org/glassfish/enterprise/concurrent/AbstractManagedExecutorService.java	(Working Copy)
@@ -74,6 +74,7 @@
     protected RejectPolicy rejectPolicy; // currently unused
     protected final boolean contextualCallback;
     protected boolean longRunningTasks;
+    protected boolean logHungThreadOnce;

     public AbstractManagedExecutorService(String name,
             ManagedThreadFactoryImpl managedThreadFactory,
@@ -81,7 +82,8 @@
             boolean longRunningTasks,
             ContextServiceImpl contextService,
             ContextSetupProvider contextCallback,
-            RejectPolicy rejectPolicy) {
+            RejectPolicy rejectPolicy,
+            boolean logHungThreadOnce) {
         this.name = name;
         this.contextSetupProvider = contextCallback;
         this.contextService = contextService;
@@ -88,6 +90,7 @@
         this.rejectPolicy = rejectPolicy;
         this.contextualCallback = false;
         this.longRunningTasks = longRunningTasks;
+        this.logHungThreadOnce = logHungThreadOnce;
         if (managedThreadFactory == null) {
             managedThreadFactory = new ManagedThreadFactoryImpl(
     name + "-ManagedThreadFactory",
@@ -216,6 +219,10 @@
         return rejectPolicy;
     }

+    public boolean isLogHungThreadOnce() {
+        return logHungThreadOnce;
+    }
+
     // managed objects methods
     public String getObjectName() {
         return null;
Index: src/main/java/org/glassfish/enterprise/concurrent/ManagedExecutorServiceImpl.java
===================================================================
--- src/main/java/org/glassfish/enterprise/concurrent/ManagedExecutorServiceImpl.java	(Revision 72)
+++ src/main/java/org/glassfish/enterprise/concurrent/ManagedExecutorServiceImpl.java	(Working Copy)
@@ -70,11 +70,13 @@
             long threadLifeTime,
             ContextServiceImpl contextService,
             RejectPolicy rejectPolicy,
-            BlockingQueue<Runnable> queue) {
+            BlockingQueue<Runnable> queue,
+            boolean logHungThreadOnce) {
         super(name, managedThreadFactory, hungTaskThreshold, longRunningTasks,
 contextService,
 contextService != null? contextService.getContextSetupProvider(): null,
-rejectPolicy);
+rejectPolicy,
+logHungThreadOnce);
         threadPoolExecutor = new ManagedThreadPoolExecutor(corePoolSize, maxPoolSize, 
 keepAliveTime, keepAliveTimeUnit, queue, 
 this.managedThreadFactory);
@@ -91,11 +93,13 @@
             long threadLifeTime,
             int queueCapacity,
             ContextServiceImpl contextService,
-            RejectPolicy rejectPolicy) {
+            RejectPolicy rejectPolicy,
+            boolean logHungThreadOnce) {
         super(name, managedThreadFactory, hungTaskThreshold, longRunningTasks,
 contextService,
 contextService != null? contextService.getContextSetupProvider(): null,
-rejectPolicy);
+rejectPolicy,
+logHungThreadOnce);

         // Create a queue for ManagedThreadPoolExecutor based on the values
         // of corePoolSize and queueCapacity. Index: src/main/java/org/glassfish/enterprise/concurrent/ManagedScheduledExecutorServiceImpl.java
===================================================================
--- src/main/java/org/glassfish/enterprise/concurrent/ManagedScheduledExecutorServiceImpl.java	(Revision 72)
+++ src/main/java/org/glassfish/enterprise/concurrent/ManagedScheduledExecutorServiceImpl.java	(Working Copy)
@@ -65,11 +65,13 @@
             TimeUnit keepAliveTimeUnit,
             long threadLifeTime,
             ContextServiceImpl contextService,
-            RejectPolicy rejectPolicy) {
+            RejectPolicy rejectPolicy,
+            boolean logHungThreadOnce) {
         super(name, managedThreadFactory, hungTaskThreshold, longRunningTasks,
 contextService,
 contextService != null? contextService.getContextSetupProvider(): null,
-rejectPolicy);
+rejectPolicy,
+logHungThreadOnce);

         threadPoolExecutor = new ManagedScheduledThreadPoolExecutor(corePoolSize, 
 this.managedThreadFactory);
Index: src/main/java/org/glassfish/enterprise/concurrent/ManagedThreadFactoryImpl.java
===================================================================
--- src/main/java/org/glassfish/enterprise/concurrent/ManagedThreadFactoryImpl.java	(Revision 72)
+++ src/main/java/org/glassfish/enterprise/concurrent/ManagedThreadFactoryImpl.java	(Working Copy)
@@ -183,6 +183,7 @@
             // called in thread t, so no need to worry about synchronization
             mt.taskStartTime = System.currentTimeMillis();
             mt.task = task;
+            mt.hungLogged = false;
         }
     }

@@ -192,6 +193,7 @@
             // called in thread t, so no need to worry about synchronization
             mt.taskStartTime = 0L;
             mt.task = null;
+            mt.hungLogged = false;
         }
     }

@@ -229,6 +231,7 @@
         final ContextHandle contextHandleForSetup;
         volatile ManagedFutureTask task = null;
         volatile long taskStartTime = 0L;
+        volatile boolean hungLogged = false;

         public ManagedThread(Runnable target, ContextHandle contextHandleForSetup) {
             super(target);
@@ -298,5 +301,13 @@
             return false;
         }

+        public boolean isHungLogged() {
+            return hungLogged;
+        }
+
+        public void setHungLogged(boolean hungLogged) {
+            this.hungLogged = hungLogged;
+        }
+
     }
 }

If changing constructor signature is problem, it is OK to keep the constructor signature and change the constructor body to call new one introduced by this patch.

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA CU_JAVAEE-8

@glassfishrobot
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant