GitHub user nsk-ume created a discussion: Grails 7: Transaction/locking
behaviour changes?
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:
```
// called concurrently by multiple consumers
@grails.gorm.transactions.Transactional
void handle(String message) {
// omitted
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]
)
}
}
}
@EqualsAndHashCode(includes = ['caseId', 'requestId'])
class Counter implements Serializable {
String caseId
String requestId
Integer value
static mapping = {
cache false
version false
id composite: ['caseId', 'requestId']
}
}
ENGINE OBJECT_NAME INDEX_NAME LOCK_TYPE LOCK_MODE LOCK_STATUS
LOCK_DATA
INNODB counter PRIMARY RECORD X,REC_NOT_GAP GRANTED
'1000220484', '9e96aed1-1947-40ed-a3eb-13428f6e0c8f'
INNODB counter PRIMARY RECORD X,REC_NOT_GAP WAITING
'1000220484', '9e96aed1-1947-40ed-a3eb-13428f6e0c8f'
INNODB counter PRIMARY RECORD X,REC_NOT_GAP WAITING
'1000220484', '9e96aed1-1947-40ed-a3eb-13428f6e0c8f'
```
* That single update on Grails 6 (under the same traffic) is taking ~500us and
on Grails 7 ~800ms
* Order of calls (based on the Hibernate transaction/session/sql logs) seems to
be exactly the same
* We are still using Hibernate 5
* Indy is disabled
Are you aware of any changes around the transaction handling/locking in Grails
7 that could have caused the issue?
Many thanks
GitHub link: https://github.com/apache/grails-core/discussions/15515
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]