[hibernate-issues] [JIRA] (HHH-13916) Provide an alternative to SessionImpl for Infinispan Pending-put owner

Gail Badner (JIRA) jira at hibernate.atlassian.net
Tue Apr 14 18:23:40 EDT 2020


Gail Badner ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Aabbef6b0-cce3-4556-9748-b721becb9c9a ) *updated* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMTBmMmMzMDQ2ZjczNDlmZjk3Yzk5MzllNDdiNDhmMGMiLCJwIjoiaiJ9 ) / Improvement ( https://hibernate.atlassian.net/browse/HHH-13916?atlOrigin=eyJpIjoiMTBmMmMzMDQ2ZjczNDlmZjk3Yzk5MzllNDdiNDhmMGMiLCJwIjoiaiJ9 ) HHH-13916 ( https://hibernate.atlassian.net/browse/HHH-13916?atlOrigin=eyJpIjoiMTBmMmMzMDQ2ZjczNDlmZjk3Yzk5MzllNDdiNDhmMGMiLCJwIjoiaiJ9 ) Provide an alternative to SessionImpl for Infinispan Pending-put owner ( https://hibernate.atlassian.net/browse/HHH-13916?atlOrigin=eyJpIjoiMTBmMmMzMDQ2ZjczNDlmZjk3Yzk5MzllNDdiNDhmMGMiLCJwIjoiaiJ9 )

Change By: Gail Badner ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Aabbef6b0-cce3-4556-9748-b721becb9c9a )

As a last resort,  {{ AbstractEntityPersister#isTransient }}  calls  {{ CacheHelper.fromSharedCache }}  to determine if an entity is cached. If the return value is non-null, then the  {{ AbstractEntityPersister#isTransient }}  returns  {{ false }} , and the return value is ignored.

When Infinispan is the cache provider,  {{ CacheHelper.fromSharedCache }}  calls [ {{ InvalidationCacheAccessDelegate#get }} |https://github.com/infinispan/infinispan/blob/9.4.x/hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/access/InvalidationCacheAccessDelegate.java#L56-L65]. If the entity is not already cached,  {{ InvalidationCacheAccessDelegate#get }}  adds a pending-put for the entity as a side-effect. The entry in the pending-put map uses a  {{ SessionImpl }}  as the map key.

If that entity really is transient, then the pending-put entry never gets cleared until it times out. Since the pending-put map contains  {{ SessionImpl }}  keys, those  {{ SessionImpl }}  objects cannot be garbage-collected until the entry times out.

If lots of data is in the process of being imported, then an  {{ OutOfMemoryError }}  could be thrown. IIUC, it is not recommended to use the cache when importing data. That is why I am calling this issue an "improvement" rather than a "bug".  {{ [WFLY-13259|https://issues.redhat.com/browse/WFLY-13259] }}  contains a test that reproduces this issue.

This improvement involves changing The original proposal was to change  {{ AbstractEntityPersister#isTransient }}  to call  {{ CachedDomainDataAccess#get }} . Unfortunately , which calls that would not work consistently. For example, if an entity is deleted, and re-persisted while the deleted entity is still locked in the cache,  {{  InvalidationCacheAccessDelegate CachedDomainDataAccess #get }}  with a will return  {{  null true  }}  , and  {{  session AbstractEntityPersister#isTransient  }}  argument. Since will incorrectly return  {{  session false  }}  is  {{ null }}  when re-persisting the new entity.

Instead ,  {{ InvalidationCacheAccessDelegate#get }}  does an improvement would be to not add store a pending-put SharedSessionContractImplementor in a PendingPut at all.

There is already a way to get a UUID for the entity session by calling SharedSessionContractImplementor#getSessionIdentifier(). Unfortunately, the implementation in AbstractSharedSessionContract indicates that frequent "UUID generations will cause a significant amount of contention".

Sanne has suggested returning a "token" that is just a new Object. I've created a [branch|https://github.com/gbadner/hibernate-core/tree/HHH-13916_token] that does this.

Infinispan would need to be updated so that PendingPut#owner is set to SharedSessionContractImplementor#getSessionToken() (instead of the SharedSessionContractImplementor object).

( https://hibernate.atlassian.net/browse/HHH-13916#add-comment?atlOrigin=eyJpIjoiMTBmMmMzMDQ2ZjczNDlmZjk3Yzk5MzllNDdiNDhmMGMiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13916#add-comment?atlOrigin=eyJpIjoiMTBmMmMzMDQ2ZjczNDlmZjk3Yzk5MzllNDdiNDhmMGMiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:185bad4 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200414/13dd3d5b/attachment.html 


More information about the hibernate-issues mailing list