kundera icon indicating copy to clipboard operation
kundera copied to clipboard

Leak in Kundera 2.12 and Datastax Java Driver

Open vanessaschissato opened this issue 10 years ago • 4 comments

I would to report that we have notice a memory leak when switched from Thrift to Datastax Java Driver that crashes our application (kundera 2.12).

vanessaschissato avatar Jul 24 '14 22:07 vanessaschissato

Could you please share few more details? -Vivek

mevivs avatar Jul 25 '14 04:07 mevivs

We have an application that makes massive inserts and reads from and to cassandra and we have identified a leak that makes our application turn down. Debugging the application, we have isolated the problem and realize that it is in the use of Kundera with DataStax Driver.

vanessaschissato avatar Aug 04 '14 14:08 vanessaschissato

Can you please share the code snippet or sample app which leads to this leak ?

Chhavi

chhavigangwal avatar Aug 20 '14 06:08 chhavigangwal

Hi guys! I faced with the same issue. This is details which can help to identify the problem

  • Gradle dependency :

compile("com.impetus.kundera.client:kundera-cassandra-ds-driver:3.4")

  • persistence.xml configuration :
...
        <properties>
           ...
            <property name="kundera.dialect" value="cassandra"/>
            <property name="kundera.client.lookup.class"
                value="com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory" />
            <property name="kundera.batch.size" value="5000" />
        </properties>
...
  • How I create EntityManager :
    @PersistenceContext(
            unitName = "cassandra",
            type = PersistenceContextType.EXTENDED,
            properties = {
                    @PersistenceProperty(name = "consistency.level", value = "QUORUM"),
                    @PersistenceProperty(name = CassandraConstants.CQL_VERSION,
                            value = CassandraConstants.CQL_VERSION_3_0)
            }
    )
    protected EntityManager em;
  • How I create entities via EntityManager:
        for (File file : files) {
            csvParser.beginParsing(file, StandardCharsets.ISO_8859_1);
            String[] row;
            while ((row = csvParser.parseNext()) != null) {
                try {
                   Entity entity = new Entity();
                    ...
                    em.save(entity);
                } catch (Throwable e) { // NOSONAR
                    LOGGER.error("Error occured during parsing row :" + Arrays.toString(row), e);
                }
            }
            csvParser.stopParsing();
        }

I suppose that after auto flush operation, GC cannot remove flushed entities. As workaround I can call clear method explicitly for EntityManager but then no sense of using auto flush operation.

Maybe I do something wrong? If it's bug, maybe there is workaround for this problem?

Odyldzhon avatar May 30 '16 22:05 Odyldzhon