Out of memory after activating Blaze-Permission
See original GitHub issueDescription
After activating BP i get a OOM heap exception on a test. This tests writes about 70k records batched:
Lists.partition(allPermissions, 1000).forEach(chunk -> {
entityManager.flush();
entityManager.clear();
chunk.forEach(entityManager::persist);
});
allPermissions
is a Collection of
PermissionCache` entries looking like this
@Entity
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor
public class PermissionCache
{
@EmbeddedId
@EqualsAndHashCode.Include
PermissionCacheId permissionId = new PermissionCacheId();
public PermissionCache(final Long spaceId, final Long uid)
{
this.permissionId.setSpaceId(spaceId);
this.permissionId.setUid(uid);
}
}
And the EmbeddedId is
@Data
@Embeddable
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class PermissionCacheId implements Serializable
{
@EqualsAndHashCode.Include
@Column(name = "space_id", columnDefinition = "INT(11)")
private Long spaceId;
@EqualsAndHashCode.Include
@Column(name = "uid", columnDefinition = "INT(11)")
private Long uid;
}
I’am using batched writes with
useServerPrepStmts=false&rewriteBatchedStatements=true
on the JDBC URL and
spring.jpa.properties.hibernate.jdbc.batch_size=1000
# suppress inspection "SpringBootApplicationProperties"
hibernate.jdbc.batch_size=1000
In the properties
I understand that batch size can be one of the reasons here - but since that code has never thrown an OOM ever yet, and does so with BP, i suspect a memory leak we are yet not aware of
Expected behavior
Perform the same way as without BP
Actual behavior
OOM exception
org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is java.lang.OutOfMemoryError: Java heap space
Caused by: java.lang.OutOfMemoryError: Java heap space
Full stacktace: https://dpaste.de/ociG
Steps to reproduce
Probably use the describe Entity with a simple JpaRepository
(save/saveAll not overriden)
Write arround 70k entries batched in one session
Environment
Version: 9.9-snapshot based on non-HEAD #846 JPA-Provider: hibernate 5.4.5 DBMS: mariadb10.3 Application Server: spring boot 2.1.7
Issue Analytics
- State:
- Created 4 years ago
- Comments:24 (20 by maintainers)
Top GitHub Comments
In spring data 1.x
CrudMethodMetadataPopulatingMethodInterceptor
was implemented as singleton and I simply tried to do it like spring data did it. I’ll fix that.This fixed this oom and nothing else broke on our side! Thank you