Mark DB as clean after compacting.

This ensures we compact the DB at the next startup if we didn't finish
compacting it at shutdown.
This commit is contained in:
akwizgran
2025-04-28 18:34:11 +01:00
parent eb45ccfe9e
commit 29f0b9d3c0

View File

@@ -89,11 +89,17 @@ class H2Database extends JdbcDatabase {
try {
c = createConnection();
closeAllConnections();
setDirty(c, false);
LOG.info("Compacting DB");
s = c.createStatement();
s.execute("SHUTDOWN COMPACT");
LOG.info("Finished compacting DB");
s.close();
c.close();
// Reopen the DB to mark it as clean after compacting
c = createConnection();
setDirty(c, false);
LOG.info("Marked DB as clean");
c.close();
} catch (SQLException e) {
tryToClose(s, LOG, WARNING);
tryToClose(c, LOG, WARNING);
@@ -126,6 +132,7 @@ class H2Database extends JdbcDatabase {
closeAllConnections();
s = c.createStatement();
s.execute("SHUTDOWN COMPACT");
LOG.info("Finished compacting DB");
s.close();
c.close();
} catch (SQLException e) {