hsqldb

Is it OK in hsqldb to invoke the CHECKPOINT sql while another sql might be in progress?


In other words, must I synchronize CHECKPOINT with another queries or can I simply execute it periodically in a dedicated thread?

My DB does not write the log. I am OK if the data is lost upon crash, but I do want to flush it periodically and make sure it is flushed when the application is terminated.

EDIT

The following items describe my scenario:

  1. Run a bunch of short unit tests inserting items in dedicated DBs using an embedded hsqldb engine.
  2. Run hsqldb as a standalone server connecting to one of the DBs created during the unit tests.
  3. Open SQL Workbench/J trying to connect to the running standalone hsqldb server.

The SQL Workbench/J shows no tables at all. But if I add CHECKPOINT after having inserted all the records, then everything is fine.


Solution

  • This question relates to a database with the data log disabled, which is not the default setting for persistent databases and is unsafe for normal operation.

    HSQLDB always performs the checkpoint safely. It uses a separate thread that waits until all connections have committed then locks the database and performs the checkpoint.

    CHECKPOINT is useful for reducing the amount of time it takes to restart a database after a crash. This does not apply to your database which has disabled the log.

    If you are not writing a log, checkpoints may be unnecessary. The use of checkpoint in this scenario is to reclaim the spaces for deleted lobs (in version 2.3.0). It also writes out all the data.

    If you want to flush the database at the end of your tests, you can execute SHUTDOWN instead.