Impetus / kundera

A JPA 2.1 compliant Polyglot Object-Datastore Mapping Library for NoSQL Datastores.Please subscribe to:
http://groups.google.com/group/kundera-discuss/subscribe
Apache License 2.0
903 stars 233 forks source link

Leak in Kundera 2.12 and Datastax Java Driver #626

Open vanessaschissato opened 10 years ago

vanessaschissato commented 10 years ago

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).

mevivs commented 10 years ago

Could you please share few more details? -Vivek

vanessaschissato commented 10 years ago

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.

chhavigangwal commented 10 years ago

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

Chhavi

Odyldzhon commented 8 years ago

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

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

...
        <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>
...
    @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;
        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?