signum-node icon indicating copy to clipboard operation
signum-node copied to clipboard

Add ability to specify SQLite synchronous mode and cache_size in the config. fix #817

Open Wekuz opened this issue 1 year ago • 3 comments

Wekuz avatar May 08 '24 20:05 Wekuz

We should allow the following states :

grafik

frankTheTank72 avatar May 09 '24 08:05 frankTheTank72

@frankTheTank72 the value of the properties are retreived in the functions getSynchronousMode() and getCacheSize(): String synchronous = propertyService.getString(Props.DB_SQLITE_SYNCHRONOUS).toUpperCase(); and int cacheSize = propertyService.getInt(Props.DB_SQLITE_CACHE_SIZE); and is then used to set the properties in the DB session (the same way journal_mode is set) with the function:

config.addDataSourceProperty("synchronous", getSynchronousMode());
config.addDataSourceProperty("cache_size", getCacheSize());

Wekuz avatar May 09 '24 11:05 Wekuz

I can prove it by running the node with a config that has these properties in it: DB.SqliteSynchronous = OFF DB.SqliteCacheSize = -4000 Then I get this output: image showing that the properties were set correctly. When running without the properties in the config I get the default values: 2 and -2000.

This custom output was gotten by adding these lines at the start of onStartupImpl():

Db.useDSLContext(ctx -> {
      logger.info(ctx.fetch("PRAGMA journal_mode").formatJSON());
      logger.info(ctx.fetch("PRAGMA synchronous").formatJSON());
      logger.info(ctx.fetch("PRAGMA cache_size").formatJSON());
    });

Wekuz avatar May 09 '24 11:05 Wekuz