Replies: 5 comments 1 reply
-
|
Hi @nsk-dvlpr, I'm not aware of any changes in this area, but we did switch to hikari by default. You do not have to use hikari and can continue to use tomcat-jdbc instead. Have you tried using that instead to see if that fixes the performance problem? Which specific Grails 7.x version are you using? We released 7.0.9 on Monday with a critical fix that caused jdbc connection properties to not be set on the Hikari configuration. Are you setting any properties that could explain this performance difference? |
Beta Was this translation helpful? Give feedback.
-
|
Hi @jdaugherty Thanks for your quick reply.
It doesn't seem that the problem is caused by the Hikari itself. Seems that the connections are not released in time by the transactions holding them up waiting for a row lock, so likely something has changed in that area. I remember seeing a similar bug during the upgrade from Grails 3.x to 4.x when Is there anything else you can think of that has changed between 6.x and 7.x that we can investigate? Thanks |
Beta Was this translation helpful? Give feedback.
-
ProblemAfter upgrading from Grails 6 to Grails 7, a concurrent @grails.gorm.transactions.Transactional
void handle(String message) {
synchroniser.update(caseId, requestId)
}
Status update(String caseId, String requestId) {
Counter.withNewSession {
Counter.withNewTransaction {
Counter.executeUpdate(
"update Counter set value = value - 1 where caseId = :caseId and requestId = :requestId",
[caseId: caseId, requestId: requestId]
)
}
}
}User reports: same config, same HikariCP Diagnosis: Connection Pool Starvation from Nested Physical TransactionsThe two-connection-per-thread patternEach thread requires two physical JDBC connections simultaneously - one for the outer Why it worked in Grails 6 but breaks in Grails 7This pattern was always fragile, but three things changed simultaneously: EvidenceThe InnoDB lock output: The ~800ms timing matches connection pool wait time + database operation, not the database How withNewSession/withNewTransaction works internally
Recommended FixesOption 1: Increase pool size (immediate fix)Set dataSource:
pooled: true
properties:
maximumPoolSize: 40 # if you expect up to 20 concurrent handle() callsOption 2: Remove withNewSession (preferred fix)If the goal is just a new transaction, Status update(String caseId, String requestId) {
Counter.withNewTransaction {
Counter.executeUpdate(
"update Counter set value = value - 1 where caseId = :caseId and requestId = :requestId",
[caseId: caseId, requestId: requestId]
)
}
}This reduces the connection requirement to one per thread. Option 3: Remove the outer @transactional (simplest fix)If void handle(String message) {
// omitted
synchroniser.update(caseId, requestId)
}This eliminates the two-connection requirement entirely. Option 4: Set explicit connectionTimeout (diagnostic aid)Set a low dataSource:
properties:
connectionTimeout: 5000 # 5 seconds instead of 30 second defaultThis makes the issue visible immediately as Broader ImplicationAny Grails application using |
Beta Was this translation helpful? Give feedback.
-
|
@nsk-dvlpr I think @jamesfredley & my answers should cover this. Can you let us know if we can close this discussion / mark it as solved? |
Beta Was this translation helpful? Give feedback.
-
|
Hi @jdaugherty, Sorry for taking so long to reply. I couldn't reproduce the issue locally, but seems that connection issues were a symptom, not a cause and the slowness was caused by our resources (CPU) quickly being maxed out (>95%) after the upgrade. I did run a simple perf test to compare the results and below you can find a comparison of Grails 6 and Grails 7 CPU usage under the same load: I'm still trying to figure out what exactly is taking those resources and if it's generic or specific to our application. Have you encountered a similar issue? |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
After upgrading our application to Grails 7 one of our endpoints became waaay slower under significant traffic.
After doing some investigation we noticed that there's a number of transactions stuck waiting for a row lock. Ultimately they are taking up all the Hikari connections and making the app unusable.
The code, that is causing the issue looks like below:
Are you aware of any changes around the transaction handling/locking in Grails 7 that could have caused the issue?
Many thanks
Beta Was this translation helpful? Give feedback.
All reactions