Unrecoverable OptimisticLockException [message #1839854] |
Tue, 30 March 2021 05:27  |
Eclipse User |
|
|
|
Hi all,
I'm maintaining a fairly extensive web application which uses Eclipselink 2.6.3 / Spring / Spring Data.
Occasionally we run into situations where one of our key entities gets out of sync in the 2nd level cache of Eclipselink.
An example workflow is:
- User performs a modifying transaction
- Eclipselink updates database correctly
- System is reading the updated entity again and shows data to user. The data presented to the user is the previous revision
- The user tries to perform the action again and now receives an OptimisticLockException
- The problem persists until we run `entityManager.getEntityManagerFactory().getCache().evictAll()` through an MBean.
There are a few frameworks involved as well as async sending of emails. However we haven't been able to reproduce the problem yet.
Has anyone experienced something similar or are there any ideas how to investigate this problem?
Thanks,
Thomas
|
|
|
|
Re: Unrecoverable OptimisticLockException [message #1840037 is a reply to message #1840028] |
Mon, 05 April 2021 20:02  |
Eclipse User |
|
|
|
Hi Chris,
Thanks for your reply. Here are my answers as good as I can:
1) The entity is modified by entity modifications through JPA managed entities. Can you please suggest for which loggers you need debug output?
2) Typically the entity is loaded by EntityManager.find(Class,Id). Notable that the entity which is causing problems is also referenced by a @OneToMany collection in a parent entity. The system reads this parent entity often through a named query.
2b) A new clear EM context by the same EMF in the same VM. (we are using Spring/Spring Data)
3) Not sure. In the affected screens only some data is shown, but this is stale. Definitely @Version and a few other fields are stale.
3b) So far I've tried "QueryHints.CACHE_USAGE, CacheUsage.DoNotCheckCache" on some key queries but with no effect.
Do you mean "eclipselink.refresh" as query hint?
I will try and implement an explicit refresh, but the problem is cropping up in quite a few place unfortunately. As a rule of thumb, do you suggest an EntityManager.refresh I've encountered an optimistic lock exception? Or should I even do an (inefficient) em.refresh() before I perform some of these failing operations?
Thanks for your help.
Cheers,
Thomas
|
|
|
Powered by
FUDForum. Page generated in 0.03510 seconds