Fast Object Database for Java - with JPA/JDO support

ODB-WeakRefPurger threads not closing at all

#1

Hi,

I am using on production ODB version 2.7.6 without big issues, but recently I tried to update it to latest version 2.8.3_05 and my server reached its limit for threads in the system because of thousands of WeakRefPurger threads. ObjectDB is creating a new ODB-WeakRefPurger thread for every DB Connection (using JDO and PersistenceManager) and not closing any of it. I've counted the DB connections during whole run of the application and it was +- the same as count of live WeakRefPurger threads.

Here is the stacktrace which is same for every WeakRefPurger thread:
 

Name: ODB-WeakRefPurger
State: WAITING on java.lang.ref.ReferenceQueue$Lock@6069d1ca
Total blocked: 0  Total waited: 1

Stack trace: 
java.base@15/java.lang.Object.wait(Native Method)
java.base@15/java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:155)
java.base@15/java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:176)
app//com.objectdb.o.RTM$f.run(RTM.java:220)

Do u need any more information for the fix ?

#2

The WeakRefPurger thread is started when a new PersistenceManagerFactory (or EntityManagerFactory) is created and exited when it is closed.

Could you please verify that every PersistenceManagerFactory instance that you open is also closed.

Currently ObjectDB waits up to 2 seconds for that thread on close. If your close operation is slow, it may indicate that this timeout may not be sufficient.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

I am closing only PersistenceManager instances, not the PersistenceManagerFactory instances. Should I close both of them at the same time ?

I can confirm that every PersistenceManager instance is closed, because I have a counter for opening and closing PersistenceManager instances to track DB connections.

Is the timeout for closing purger threads configurable, so I could try raising it ?

#4

> I am closing only PersistenceManager instances, not the PersistenceManagerFactory instances. Should I close both of them at the same time?

You must close every PersistenceManagerFactory instance that you open. When to do it is dependent on your application. For example, in a web application you may create one PersistenceManagerFactory on startup and close it on shutdown, but create and close a separate PersistenceManager per request.

It is very similar to JPA's EntityManagerFactory and EntityManager, so please see this manual page.

> Is the timeout for closing purger threads configurable, so I could try raising it?

No, but the 2-seconds timeout might be sufficient for everyone, and even if the timeout is exceeded, the thread is still expected to be closed anyway, if the JVM is still running (i.e. after returning from close).

 

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#5

Thank You for the explanation. I am now caching 1 instance of PersistenceManagerFactory per DB file for the whole running of the app and creating/closing PersistenceManager instances for each request and the problem seems to be solved.

Post Reply