You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2008/11/12 12:56:37 UTC

DO NOT REPLY [Bug 46193] New: Potential Thread problem with SessionManager

https://issues.apache.org/bugzilla/show_bug.cgi?id=46193

           Summary: Potential Thread problem with SessionManager
           Product: Tomcat 6
           Version: 6.0.16
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: hgomez@apache.org


Hi to all,

Under heavly load (about 500k/requests by day), I see this error about
30 times last week on a Tomcat 6.0.16 (with libtcnative 1.1.14 on a
Suse SLES 10 and IBM JDK 1.6-jvmxi3260-20080415_18762).

We have many HTTP sessions on our application and so frequent session cleanup
done by Tomcat.

We see theses errors :

WARNING: Exception processing manager
org.apache.catalina.session.StandardManager@66196619 background
process
Throwable occurred: java.lang.ArrayIndexOutOfBoundsException
       at java.util.AbstractCollection.toArray(Unknown Source)
       at
org.apache.catalina.session.ManagerBase.findSessions(ManagerBase.java:873)
       at
org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:676)
       at
org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:667)
       at
org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1316)
       at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
       at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
       at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
       at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
       at java.lang.Thread.run(Thread.java:735)
7 nov. 2008 16:18:21 org.apache.catalina.core.ContainerBase backgroundProcess

---

WARNING: Exception processing manager
org.apache.catalina.session.StandardManager@66196619 background
process
Throwable occurred: java.lang.IllegalMonitorStateException
       at
java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:140)
       at
java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1188)
       at
java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:444)
       at
java.util.concurrent.ConcurrentHashMap$Segment.remove(ConcurrentHashMap.java:555)
       at
java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:936)
       at org.apache.catalina.session.ManagerBase.remove(ManagerBase.java:885)
       at
org.apache.catalina.session.StandardSession.expire(StandardSession.java:743)
       at
org.apache.catalina.session.StandardSession.isValid(StandardSession.java:592)
       at
org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:682)
       at
org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:667)
       at
org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1316)
       at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
       at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
       at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
       at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
       at java.lang.Thread.run(Thread.java:735)


We take a look at ManagerBase and the sessions is using ConcurrentHashMap.

We wonder if they couldn't be some Concurrency problems when some threads are
updating the sessions Map while ManagerBase try to dump the sessions into
sessions array in findSessions.

>From ConcurrentHashMap comments :

 * Enumerations return elements reflecting the state of the hash table
 * at some point at or since the creation of the iterator/enumeration.
 * They do <em>not</em> throw
 * {@link ConcurrentModificationException}.  However, iterators are
 * designed to be used by only one thread at a time.


Regards


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 46193] Potential Thread problem with SessionManager

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46193


Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #1 from Konstantin Kolinko <kn...@gmail.com>  2008-12-28 08:45:09 PST ---
It is JDK issue, not Tomcat one.

As said in the class summary ([1]) (and the JavaDoc serves as the official spec
for the class), this class is designed to be a replacement for
java.util.Hashtable. If the implementation does not behave, it is not Tomcat to
blame.

[1]
http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html

The first stacktrace of yours is a ConcurentHashMap.values().toArray(T[]) call,
the second one is ConcurentHashMap.remove(Object). The both ones are valid API
calls.

The second one is failing due to unpaired lock() / unlock() calls inside a
segment of ConcurentHashMap. All those call pairs are internal to
ConcurentHashMap implementation and do not span more that one API method call.

The first one is specifically addressed in Sun JDK implementation of
AbstractCollection.toArray(), see bug 5067025 [2] for the date when it was
spotted and fixed.

[2] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5067025

I wonder, why you are still seeing such issues, as ConcurentHashMap class is
available since JDK 5.0 and should have been well tested in practice since
then. It might be there is something more subtle, specific to your CPU /
libraries, or else it is a regression, and there are good chances that it is
already fixed.

You may try to solve the issue with your JDK vendor.

> * However, iterators are
> * designed to be used by only one thread at a time.

It does not apply to your stack traces. There is a toArray() API call. Well,
most if not all iterators are to be used by only one thread at a time.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org