Empty DB - Defrag failed

Help
MichaeL
2013-05-09
2014-01-19
  • MichaeL
    MichaeL
    2013-05-09

    Hi,

    I have a database with three tables. Each table is empty. Thus, no  *.data file exists. If I open the database and close it again, I get some exceptions - see below. The error occurs with the following simple code - (I try hsqldb-20130507.221525-45.jar):

    package test;
    import java.sql.Connection;
    import java.sql.DriverManager;
    public class HSQLDBTest {
        public static void main(String args[])  {
            try {
                Class.forName( "org.hsqldb.jdbcDriver" );
                Connection conn = DriverManager.getConnection("jdbc:hsqldb:file:stack;shutdown=true","sa","");      
                conn.prepareStatement("CHECKPOINT DEFRAG").execute();
                conn.prepareStatement("SHUTDOWN").execute();
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }
    }
    

    It seems, that the CHECKPOINT DEFRAG makes problems. I uploaded a sample db here. With the stable version of 2.2.9, no exception is given. Is there a problem with the (current) snapshot?

    regards Micha

    2013-05-10T00:14:42.928+0200  SEVERE  dataFileCache close failed
    java.lang.NullPointerException
        at java.io.File.<init>(Unknown Source)
        at org.hsqldb.lib.FileUtil.isStreamElement(Unknown Source)
        at org.hsqldb.lib.FileUtil.removeElement(Unknown Source)
        at org.hsqldb.persist.DataFileCache.deleteFile(Unknown Source)
        at org.hsqldb.persist.DataFileCache.deleteBackup(Unknown Source)
        at org.hsqldb.persist.DataFileCache.close(Unknown Source)
        at org.hsqldb.persist.DataFileDefrag.process(Unknown Source)
        at org.hsqldb.persist.DataFileCache.defrag(Unknown Source)
        at org.hsqldb.persist.Log.defrag(Unknown Source)
        at org.hsqldb.persist.Log.checkpoint(Unknown Source)
        at org.hsqldb.persist.Logger.checkpointInternal(Unknown Source)
        at org.hsqldb.persist.Logger.checkpoint(Unknown Source)
        at org.hsqldb.StatementCommand.getResult(Unknown Source)
        at org.hsqldb.StatementCommand.execute(Unknown Source)
        at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
        at org.hsqldb.Session.execute(Unknown Source)
        at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
        at org.hsqldb.jdbc.JDBCPreparedStatement.execute(Unknown Source)
        at test.HSQLDBTest.main(HSQLDBTest.java:24)
    2013-05-10T00:14:42.929+0200  SEVERE  defrag failed 
    org.hsqldb.HsqlException: file input/output errorerror java.lang.NullPointerException closing file - file stack.data.new
        at org.hsqldb.error.Error.error(Unknown Source)
        at org.hsqldb.persist.DataFileCache.close(Unknown Source)
        at org.hsqldb.persist.DataFileDefrag.process(Unknown Source)
        at org.hsqldb.persist.DataFileCache.defrag(Unknown Source)
        at org.hsqldb.persist.Log.defrag(Unknown Source)
        at org.hsqldb.persist.Log.checkpoint(Unknown Source)
        at org.hsqldb.persist.Logger.checkpointInternal(Unknown Source)
        at org.hsqldb.persist.Logger.checkpoint(Unknown Source)
        at org.hsqldb.StatementCommand.getResult(Unknown Source)
        at org.hsqldb.StatementCommand.execute(Unknown Source)
        at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
        at org.hsqldb.Session.execute(Unknown Source)
        at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
        at org.hsqldb.jdbc.JDBCPreparedStatement.execute(Unknown Source)
        at test.HSQLDBTest.main(HSQLDBTest.java:24)
    Caused by: java.lang.NullPointerException
        at java.io.File.<init>(Unknown Source)
        at org.hsqldb.lib.FileUtil.isStreamElement(Unknown Source)
        at org.hsqldb.lib.FileUtil.removeElement(Unknown Source)
        at org.hsqldb.persist.DataFileCache.deleteFile(Unknown Source)
        at org.hsqldb.persist.DataFileCache.deleteBackup(Unknown Source)
        ... 14 more
    java.sql.SQLException: org.hsqldb.HsqlException: file input/output errorerror java.lang.NullPointerException closing file - file stack.data.new in statement [CHECKPOINT DEFRAG]
        at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
        at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
        at org.hsqldb.jdbc.JDBCPreparedStatement.execute(Unknown Source)
        at test.HSQLDBTest.main(HSQLDBTest.java:24)
    Caused by: org.hsqldb.HsqlException: org.hsqldb.HsqlException: file input/output errorerror java.lang.NullPointerException closing file - file stack.data.new
        at org.hsqldb.error.Error.error(Unknown Source)
        at org.hsqldb.persist.DataFileDefrag.process(Unknown Source)
        at org.hsqldb.persist.DataFileCache.defrag(Unknown Source)
        at org.hsqldb.persist.Log.defrag(Unknown Source)
        at org.hsqldb.persist.Log.checkpoint(Unknown Source)
        at org.hsqldb.persist.Logger.checkpointInternal(Unknown Source)
        at org.hsqldb.persist.Logger.checkpoint(Unknown Source)
        at org.hsqldb.StatementCommand.getResult(Unknown Source)
        at org.hsqldb.StatementCommand.execute(Unknown Source)
        at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
        at org.hsqldb.Session.execute(Unknown Source)
        ... 3 more
    Caused by: org.hsqldb.HsqlException: file input/output errorerror java.lang.NullPointerException closing file - file stack.data.new
        at org.hsqldb.error.Error.error(Unknown Source)
        at org.hsqldb.persist.DataFileCache.close(Unknown Source)
        ... 13 more
    Caused by: java.lang.NullPointerException
        at java.io.File.<init>(Unknown Source)
        at org.hsqldb.lib.FileUtil.isStreamElement(Unknown Source)
        at org.hsqldb.lib.FileUtil.removeElement(Unknown Source)
        at org.hsqldb.persist.DataFileCache.deleteFile(Unknown Source)
        at org.hsqldb.persist.DataFileCache.deleteBackup(Unknown Source)
        ... 14 more
    
     
  • Fred Toussi
    Fred Toussi
    2013-05-10

    Thanks for reporting. This situation was not checked in the new code for CHECKPOINT DEFRAG. It will be fixed for the next snapshot, available by Monday.

     
  • MichaeL
    MichaeL
    2013-05-15

    Hi Fredt,

    works for me!

    Thank you
    Micha