Comments (7)
Alternatively one can add to e.g. LoadManyRequest.createQuery code to use the existing transaction:
if (this.transaction() != null) {
query.usingTransaction(transaction);
}
Or in DefaultBeanLoader
void loadMany(LoadManyRequest loadRequest) {
SpiQuery<?> query = loadRequest.createQuery(server);
query.usingTransaction(loadRequest.transaction());
executeQuery(loadRequest, query);
loadRequest.postLoad();
}
This feels like a better approach. Where the last one seems like it could be the fix, because it mirrors loadBean in the same class.
from ebean.
It appears the second connection is for a ImplicitReadOnlyTransaction which has its own connection.
First connection is used:
logSql:405, CQueryEngine (io.ebeaninternal.server.query)
findMany:348, CQueryEngine (io.ebeaninternal.server.query)
findMany:126, DefaultOrmQueryEngine (io.ebeaninternal.server.query)
findList:403, OrmQueryRequest (io.ebeaninternal.server.core)
findList:1430, DefaultServer (io.ebeaninternal.server.core)
findOne:1060, DefaultServer (io.ebeaninternal.server.core)
findOne:1569, DefaultOrmQuery (io.ebeaninternal.server.querydefn)
findOne:429, DefaultExpressionList (io.ebeaninternal.server.expression)
byUUID:54, UserFinder (com.nedap.healthcare.administration.authorization.finder)
...
Second connection is used:
sql:40, DTxnLogger (io.ebeaninternal.server.logger)
logSql:443, ImplicitReadOnlyTransaction (io.ebeaninternal.server.transaction)
logSql:405, CQueryEngine (io.ebeaninternal.server.query)
findMany:348, CQueryEngine (io.ebeaninternal.server.query)
findMany:126, DefaultOrmQueryEngine (io.ebeaninternal.server.query)
findList:403, OrmQueryRequest (io.ebeaninternal.server.core)
findList:1430, DefaultServer (io.ebeaninternal.server.core)
findList:1409, DefaultServer (io.ebeaninternal.server.core)
executeQuery:149, DefaultBeanLoader (io.ebeaninternal.server.core)
loadMany:37, DefaultBeanLoader (io.ebeaninternal.server.core)
loadMany:462, DefaultServer (io.ebeaninternal.server.core)
loadSecondaryQuery:98, DLoadManyContext (io.ebeaninternal.server.loadcontext)
executeSecondaryQueries:192, DLoadContext (io.ebeaninternal.server.loadcontext)
executeSecondaryQueries:121, OrmQueryRequest (io.ebeaninternal.server.core)
findMany:357, CQueryEngine (io.ebeaninternal.server.query)
findMany:126, DefaultOrmQueryEngine (io.ebeaninternal.server.query)
findList:403, OrmQueryRequest (io.ebeaninternal.server.core)
findList:1430, DefaultServer (io.ebeaninternal.server.core)
findOne:1060, DefaultServer (io.ebeaninternal.server.core)
findOne:1569, DefaultOrmQuery (io.ebeaninternal.server.querydefn)
findOne:429, DefaultExpressionList (io.ebeaninternal.server.expression)
byUUID:54, UserFinder (com.nedap.healthcare.administration.authorization.finder)
...
from ebean.
It seems this setup maybe intended for use with a ReadonlyDatasource. But setting that up shows that the two nested getConnections both claim from the readonly datasource, thus does not solve the problem. (The first working get/return claims from the normal pool.)
from ebean.
Below are the two stacktraces of the two claims for a connection without returning in between.
getConnection:276, SemaphoreConcurrentLinkedDequeManagedConnectionPool (org.jboss.jca.core.connectionmanager.pool.mcp)
getSimpleConnection:640, AbstractPool (org.jboss.jca.core.connectionmanager.pool)
getConnection:605, AbstractPool (org.jboss.jca.core.connectionmanager.pool)
getManagedConnection:624, AbstractConnectionManager (org.jboss.jca.core.connectionmanager)
getManagedConnection:440, TxConnectionManagerImpl (org.jboss.jca.core.connectionmanager.tx)
allocateConnection:789, AbstractConnectionManager (org.jboss.jca.core.connectionmanager)
getConnection:151, WrapperDataSource (org.jboss.jca.adapters.jdbc)
getConnection:64, WildFlyDataSource (org.jboss.as.connector.subsystems.datasources)
createReadOnlyTransaction:32, TransactionFactoryBasicWithRead (io.ebeaninternal.server.transaction)
createReadOnlyTransaction:294, TransactionManager (io.ebeaninternal.server.transaction)
createReadOnlyTransaction:2153, DefaultServer (io.ebeaninternal.server.core)
initTransIfRequired:219, OrmQueryRequest (io.ebeaninternal.server.core)
findList:1429, DefaultServer (io.ebeaninternal.server.core)
findOne:1060, DefaultServer (io.ebeaninternal.server.core)
findOne:1569, DefaultOrmQuery (io.ebeaninternal.server.querydefn)
findOne:429, DefaultExpressionList (io.ebeaninternal.server.expression)
byUUID:54, UserFinder (com.nedap.healthcare.administration.authorization.finder)
byUuid:607, UserResource (com.nedap.healthcare.administration.rest)
userByUuid:155, UserResource (com.nedap.healthcare.administration.rest)
...
getConnection:276, SemaphoreConcurrentLinkedDequeManagedConnectionPool (org.jboss.jca.core.connectionmanager.pool.mcp)
getSimpleConnection:640, AbstractPool (org.jboss.jca.core.connectionmanager.pool)
getConnection:605, AbstractPool (org.jboss.jca.core.connectionmanager.pool)
getManagedConnection:624, AbstractConnectionManager (org.jboss.jca.core.connectionmanager)
getManagedConnection:440, TxConnectionManagerImpl (org.jboss.jca.core.connectionmanager.tx)
allocateConnection:789, AbstractConnectionManager (org.jboss.jca.core.connectionmanager)
getConnection:151, WrapperDataSource (org.jboss.jca.adapters.jdbc)
getConnection:64, WildFlyDataSource (org.jboss.as.connector.subsystems.datasources)
createReadOnlyTransaction:32, TransactionFactoryBasicWithRead (io.ebeaninternal.server.transaction)
createReadOnlyTransaction:294, TransactionManager (io.ebeaninternal.server.transaction)
createReadOnlyTransaction:2153, DefaultServer (io.ebeaninternal.server.core)
initTransIfRequired:219, OrmQueryRequest (io.ebeaninternal.server.core)
findList:1429, DefaultServer (io.ebeaninternal.server.core)
findList:1409, DefaultServer (io.ebeaninternal.server.core)
executeQuery:149, DefaultBeanLoader (io.ebeaninternal.server.core)
loadMany:37, DefaultBeanLoader (io.ebeaninternal.server.core)
loadMany:462, DefaultServer (io.ebeaninternal.server.core)
loadSecondaryQuery:98, DLoadManyContext (io.ebeaninternal.server.loadcontext)
executeSecondaryQueries:192, DLoadContext (io.ebeaninternal.server.loadcontext)
executeSecondaryQueries:121, OrmQueryRequest (io.ebeaninternal.server.core)
findMany:357, CQueryEngine (io.ebeaninternal.server.query)
findMany:126, DefaultOrmQueryEngine (io.ebeaninternal.server.query)
findList:403, OrmQueryRequest (io.ebeaninternal.server.core)
findList:1430, DefaultServer (io.ebeaninternal.server.core)
findOne:1060, DefaultServer (io.ebeaninternal.server.core)
findOne:1569, DefaultOrmQuery (io.ebeaninternal.server.querydefn)
findOne:429, DefaultExpressionList (io.ebeaninternal.server.expression)
byUUID:54, UserFinder (com.nedap.healthcare.administration.authorization.finder)
byUuid:607, UserResource (com.nedap.healthcare.administration.rest)
userByUuid:155, UserResource (com.nedap.healthcare.administration.rest)
...
The second stacktrace has two different requests objects in DefaultServer line 1429. They are constructed just above in line 1414. It would make sense that the second request reuses the readonly connection obtained by the first request.
Under EBean 12 this nesting indeed does not happen. And if an explicit JTA transaction is started, both request use that connection.
from ebean.
I was able to patch the behaviour by introducing a ThreadLocal variable in OrmQueryRequest.initTransIfRequired and solely for createReadOnlyTransaction store the first transaction within a thread, and return that on subsequent calls. Does not seem like the correct way to fix it, but it appears to work.
from ebean.
Any idea when a bugfix release will come out?
from ebean.
Should be on the way to central, so should be available in about 20 minutes.
from ebean.
Related Issues (20)
- Disabling batching through configuration HOT 2
- Question: Reason for transaction not being reused? HOT 10
- LimitOffsetPagedList add getTotalCount cache HOT 1
- After packaging Javalin + Ebean into a JAR file, it cannot run:jakarta.persistence.PersistenceException: hxy.dragon.model.Customer is NOT an Entity Bean registered with this server HOT 2
- Feature request: add query bean copy() method to TQRootBean interface HOT 2
- Empty OneToMany when overflowing LazyLoadBatchSize and mixed queries HOT 11
- IntelliJ IDEA 2024.1 needs updated plugin HOT 1
- ebean-gradle-plugin: ERROR [Test worker] io.ebean.internal::Error in deployment / Error trying to create the prototypeEntityBean for class HOT 14
- [12.16.3] Add support for "NoTimeZone", specifically to use no timeZone with MySql
- How to delete permanently use Qbean when use SoftDelete HOT 3
- ddl-generator: Identity for PK is always generated HOT 5
- Ebean-Data (auto generated repositories)? HOT 1
- querybean-generator incremental annotation processing not working in gradle HOT 8
- ReadOnly transactions does not honor isolation-level HOT 1
- Q: is there a way to invalidate lazy-loaded entity bean field? HOT 17
- Sorting on a ManyToMany relationship HOT 1
- No delay on SIGTERM before shutting down future count ThreadPoolExecutor HOT 2
- Unable to use kapt to generate querybean in Maven HOT 1
- JtraTransactionManager keeps reference to already closed scope (and Transaction/connection ThreadLocal) when JtaTxnListener#afterCompletion is called by a different thread HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ebean.