Write operations are not allowed in read-only mode (FlushMode.MANUAL):
Grails 1.3.7
We have a service method that merges 2 users. There are quite a few pieces to this because of the amount of data so that is quite a bit of reading, updating, and writing. We have transactional=true in the service. I understand that the default FlushMode for Grails is AUTO. And I understand what that error message means.
However, it doesn't happen locally and it doesn't happen in our staging environment. All of which are running the identical version of MySQL with identical privileges (password is开发者_如何转开发 the exception).
I know I can change the default FlushMode behavior but I'm hesitant since I can't duplicate the behavior on any environment than production. Right now I'm just wondering if there is anything that could cause this that wouldn't actually be related to the FlushMode?
The verbatim error message is:
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
I'm seeing errors similar to these in my Grails 1.3.7 application as well. In my case, my back-end DB was having some lock contention issues that cause the app to throw a CannotAcquireLockException. After hitting one of these we'd see lots of the exact same InvalidDataAccessApiUsageExceptions you're seeing (coincidentally, also only happened in our prod environment, not dev or test)
You may want check to ensure your prod DB user has access to locking features in MySQL, and check for other database-related exceptions that may be the actual root cause.
精彩评论