Apparently, in Lucee the entityLoad call gets Hibernate to keep running its classloader at runtime. The result is that one request would hold a handle on the Hibernate session, blocking access to any other request threads.
Not only that, the running (blocking) thread takes too long. Sometimes up to minutes. Evidently because it gets Hibernate to load a class. The blocked requests (invariable entityLoad calls themselves) eventually time out.
The higher the load, the more likely this issue will be triggered. Which is why I have not yet been able to repro the issue. As I have not been able to simulate the traffic pattern that causes it.
Nevertheless, I have discussed the issue earlier in the post " Are Lucee’s custom class loaders single-threaded or multithreaded?"
The stacktrace typically ends in:
…
[entityLoad call from custom, user-defined CFC]
lucee.runtime.functions.orm.EntityLoad.call(EntityLoad.java:70)
org.lucee.extension.orm.hibernate.HibernateORMSession.loadAsArray(HibernateORMSession.java:676)
org.lucee.extension.orm.hibernate.HibernateORMSession.load(HibernateORMSession.java:851)
org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:370)
org.hibernate.internal.SessionImpl.list(SessionImpl.java:1851)
org.hibernate.metamodel.internal.MetamodelImpl.getImplementors(MetamodelImpl.java:661)
org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:130)
java.lang.Class.forName(Unknown Source)
java.lang.Class.forName0(Native Method)
The question is, why is it that whenever Lucee runs entityLoad it gets Hibernate to run the classloader?
One consequence is that we, on occasion, have to restart Lucee instances. That is the order of the day now for our application. It is becoming a deal breaker for the development team, making Lucee adoption difficult.
Please kindly offer any suggestions you may have.
I have attached a typical thread dump and error report.
2 examples of blocked calls:
/* /nl/dvnt/stdmtr/service/UserData.cfc:949 */
var aResult=entityLoad("UserResults", {userId: nUserId, exerciseUUID: sExerciseUuid, exerciseId: nExerciseId});
/* /nl/dvnt/stdmtr/service/UserData.cfc:992 */
var aResult=entityLoad("UserAnswers", {userId: nUserId, exerciseUUID: sExerciseUuid, exerciseId: nExerciseId}, "sortOrder asc");
Lucee 5.3.9.163-SNAPSHOT on CommandBox
Hibernate 5.4.29.15-BETA
Windows Server 2016
Thread Dump - sm1-2 10.05 17-11-2022.txt (735.3 KB)
timeout-error-report.txt (11.7 KB)