[JBoss JIRA] (ISPN-3953) JPACacheStore should not load all entities in memory
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-3953?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero commented on ISPN-3953:
---------------------------------------
Note that the window models which have been applied don't clear the Session.
I've opened new issues: ISPN-4538, ISPN-4536
> JPACacheStore should not load all entities in memory
> ----------------------------------------------------
>
> Key: ISPN-3953
> URL: https://issues.jboss.org/browse/ISPN-3953
> Project: Infinispan
> Issue Type: Enhancement
> Security Level: Public(Everyone can see)
> Components: Loaders and Stores
> Reporter: Emmanuel Bernard
> Assignee: Radim Vansa
> Labels: 630, 630betablocker
> Fix For: 7.0.0.Alpha3
>
>
> Today several methods use getResultList() and load either all keys or all entities for a given entity type in- memory at the same time.
> This will likely blow up for big tables.
> There are two solutions:
> ## Use Hibernate's specific features
> Hibernate ORM has a session.scroll() method that offers a FORWARD_ONLY scrollable result set. You can then load data and regularly (every 100?) clear the session before hitting the next result. This will diminish greatly the memory pressure.
> ## Use a window model
> get the number of entities in the table select count(*)
> Then use setFirstResult / setMaxResults to navigate the data with a sliding window and clear the session every time you move the window.
> This won't be as efficient as Hibernate ORM's specific approach but will do the work except on database that don't support the ability to start the results at the nth element. Look up Hibernate dialects for more info.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
10 years, 6 months
[JBoss JIRA] (ISPN-4538) JPACacheStore#process is not clearing the PersistenceContext regularly
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-4538?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero commented on ISPN-4538:
---------------------------------------
If they are primitives they will not be managed but embeddable types will be tracked. Also an ID might have relations and load much more, if the relation is eager.. not likely but it's dangerous to decide not to invoke the clear.
> JPACacheStore#process is not clearing the PersistenceContext regularly
> ----------------------------------------------------------------------
>
> Key: ISPN-4538
> URL: https://issues.jboss.org/browse/ISPN-4538
> Project: Infinispan
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Loaders and Stores
> Reporter: Sanne Grinovero
> Assignee: Radim Vansa
>
> This is going to cause OOM when the key is not a primitive but for example and embeddable component and the primary EntityManager decides to manage it.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
10 years, 6 months
[JBoss JIRA] (ISPN-4538) JPACacheStore#process is not clearing the PersistenceContext regularly
by Radim Vansa (JIRA)
[ https://issues.jboss.org/browse/ISPN-4538?page=com.atlassian.jira.plugin.... ]
Radim Vansa commented on ISPN-4538:
-----------------------------------
Do I need to clear the entity manager if I only scroll through projection of IDs? (It does not make sense to me to keep the IDs without respective entities in EM). The entries themselves are loaded is separate EM, which is closed for each entry.
> JPACacheStore#process is not clearing the PersistenceContext regularly
> ----------------------------------------------------------------------
>
> Key: ISPN-4538
> URL: https://issues.jboss.org/browse/ISPN-4538
> Project: Infinispan
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Loaders and Stores
> Reporter: Sanne Grinovero
> Assignee: Radim Vansa
>
> This is going to cause OOM when the key is not a primitive but for example and embeddable component and the primary EntityManager decides to manage it.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
10 years, 6 months
[JBoss JIRA] (ISPN-4535) size() operator on JPACacheStore should expect larger than int
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-4535?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero commented on ISPN-4535:
---------------------------------------
I'm not sure what should be done, but casting to int is definitely wrong as you will have larger results.
Would at least be better to log an error rather than throwing a cast exception.
+1 for your idea of a "saturated cast", but it needs to be documented.
Ideally, the API needs to be changed in .next
> size() operator on JPACacheStore should expect larger than int
> --------------------------------------------------------------
>
> Key: ISPN-4535
> URL: https://issues.jboss.org/browse/ISPN-4535
> Project: Infinispan
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Loaders and Stores
> Reporter: Sanne Grinovero
> Assignee: Radim Vansa
>
> the return type of the CacheStore#size() is int but it's common in databases to store way more.
> The query performing the count operation is doing a cast to integer, this will fail.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
10 years, 6 months
[JBoss JIRA] (ISPN-4535) size() operator on JPACacheStore should expect larger than int
by Radim Vansa (JIRA)
[ https://issues.jboss.org/browse/ISPN-4535?page=com.atlassian.jira.plugin.... ]
Radim Vansa commented on ISPN-4535:
-----------------------------------
The CacheStore API is set, nothing but int can be returned. Do you recommend rather saturated cast? (anything greater than INT_MAX will become INT_MAX)
> size() operator on JPACacheStore should expect larger than int
> --------------------------------------------------------------
>
> Key: ISPN-4535
> URL: https://issues.jboss.org/browse/ISPN-4535
> Project: Infinispan
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Loaders and Stores
> Reporter: Sanne Grinovero
> Assignee: Radim Vansa
>
> the return type of the CacheStore#size() is int but it's common in databases to store way more.
> The query performing the count operation is doing a cast to integer, this will fail.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
10 years, 6 months
[JBoss JIRA] (ISPN-4539) JPACacheStore is associating same objects to multiple EntityManagers
by Sanne Grinovero (JIRA)
Sanne Grinovero created ISPN-4539:
-------------------------------------
Summary: JPACacheStore is associating same objects to multiple EntityManagers
Key: ISPN-4539
URL: https://issues.jboss.org/browse/ISPN-4539
Project: Infinispan
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: Loaders and Stores
Reporter: Sanne Grinovero
Assignee: Radim Vansa
An object instance can be managed by at most one EntityManager (at a time). The pattern used in the JPACacheStore's process method is illegal.
The solution is to clear the primary EntityManager and pass the detached data to the second EntityManager.
There is a comment about something similar being needed in MySQL when there is a single connection; I'd rather check to have multiple connections available to avoid deadlocks.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
10 years, 6 months
[JBoss JIRA] (ISPN-4538) JPACacheStore#process is not clearing the PersistenceContext regularly
by Sanne Grinovero (JIRA)
Sanne Grinovero created ISPN-4538:
-------------------------------------
Summary: JPACacheStore#process is not clearing the PersistenceContext regularly
Key: ISPN-4538
URL: https://issues.jboss.org/browse/ISPN-4538
Project: Infinispan
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: Loaders and Stores
Reporter: Sanne Grinovero
Assignee: Radim Vansa
This is going to cause OOM when the key is not a primitive but for example and embeddable component and the primary EntityManager decides to manage it.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
10 years, 6 months
[JBoss JIRA] (ISPN-4537) JPACacheStore should lookup entity and metadata in a single operation
by Sanne Grinovero (JIRA)
Sanne Grinovero created ISPN-4537:
-------------------------------------
Summary: JPACacheStore should lookup entity and metadata in a single operation
Key: ISPN-4537
URL: https://issues.jboss.org/browse/ISPN-4537
Project: Infinispan
Issue Type: Enhancement
Security Level: Public (Everyone can see)
Components: Loaders and Stores
Reporter: Sanne Grinovero
Assignee: Radim Vansa
Resolving ISPN-4529 would make it possible to fetch the two entries in a single operation: now each use case which requires a read will do two sequential roundtrips to the database.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
10 years, 6 months