db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johannes Stamminger <Johannes.Stammin...@astrium.eads.net>
Subject Too many open files
Date Thu, 05 Feb 2009 18:19:54 GMT

Hi,

I observed my automated tests starting failing after having implemented some 
with error "Too many open files" on creating a new database within the tests 
(first while using from EclipseLink JPA impl, see thread 
http://www.eclipse.org/newsportal/article.php?id=571&group=eclipse.rt.eclipselink#571).


On further investigation it seems to me that after closing an embedded derby 
database some file handles (.dat, .lck and .log) are kept open (checked using 
lsof).

Below you'll find my test failing with using 
 - derby-10.4.2.0
 - junit 3.8.1
 - kubuntu 8.04
 - open files soft and hard limit being set to 2048 (once was 1024 but I 
increased it while this error first occurrence)

Note that the close messages out of my teardown impl appear. Though I do not 
see any shutdown related messages in derby.log, only startup and later on 
failure messages appear there.


Did I miss something?
Any suggestions are highly apreciated ;-).


Best regards,
JOhannes


*****

import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import junit.extensions.RepeatedTest;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;


public class DerbyBaseTest extends TestCase {
    private static final File TEST_DIR;
    static {
        try {
            TEST_DIR = File.createTempFile(DerbyBaseTest.class.getName(), "");
            TEST_DIR.delete();
            TEST_DIR.mkdirs();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    private static int fInstance;
    private Connection fDirectDerbyConnection;

    public void testDirectlyEmbeddedDerby() throws Exception {
        openDirectly();
    }

    private void openDirectly() throws Exception {
        Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
        final String name = "test-registry";
        final File registryDir = new File(TEST_DIR, "run-" + fInstance);
        final String dbDir = new File(registryDir, name).getPath();
        fDirectDerbyConnection = DriverManager.getConnection("jdbc:derby:" + 
dbDir + ";create=true");
    }

    protected void setUp() throws Exception {
        fInstance++;
        super.setUp();
    }

    protected void tearDown() throws Exception {
        closeDirectDerby();
    }

    private void closeDirectDerby() throws SQLException {
        if (fDirectDerbyConnection != null) {
            fDirectDerbyConnection.close();
            System.out.println("run " + fInstance + " db closed");
        }
    }

    public static Test suite() {
        return new RepeatedTest(new TestSuite(DerbyBaseTest.class), 100);
    }
}

This email (including any attachments) may contain confidential and/or privileged information
or information otherwise protected from disclosure. If you are not the intended recipient,
please notify the sender immediately, do not copy this message or any attachments and do not
use it for any purpose or disclose its content to any person, but delete this message and
any attachments from your system. Astrium disclaims any and all liability if this email transmission
was virus corrupted, altered or falsified.
---------------------------------------------------------
Astrium GmbH Vorsitzender des Aufsichtsrates: Thomas Mueller - Geschaeftsfuehrung: Evert Dudok
(Vorsitzender), Dr. Reinhold Lutz, Pablo Salame Fischer, Guenter Stamerjohanns
Sitz der Gesellschaft: Muenchen - Registergericht: Amtsgericht Muenchen, HRB Nr. 107 647 


Weitere Informationen ueber EADS Astrium @ http://www.astrium.eads.net/

Mime
View raw message