From c5f4098b5b271c8b617870f71013f1d8b9f9011b Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Tue, 13 May 2025 14:01:41 +0100 Subject: [PATCH] db: add max vlog size setting --- config.go | 2 ++ config/config-base.yaml | 13 +++++++++++++ storage.go | 1 + 3 files changed, 16 insertions(+) diff --git a/config.go b/config.go index c58f425..88b0013 100644 --- a/config.go +++ b/config.go @@ -155,6 +155,8 @@ func (app *appContext) loadConfig() error { app.MustSetValue("ui", "port", "8056") app.MustSetValue("advanced", "tls_port", "8057") + app.MustSetValue("advanced", "value_log_size", "1024") + pwrMethods := []string{"allow_pwr_username", "allow_pwr_email", "allow_pwr_contact_method"} allDisabled := true for _, v := range pwrMethods { diff --git a/config/config-base.yaml b/config/config-base.yaml index ff427d7..1da810b 100644 --- a/config/config-base.yaml +++ b/config/config-base.yaml @@ -330,6 +330,19 @@ sections: requires_restart: true type: password description: Leave blank for no Authentication. + - setting: value_log_note + name: 'Value Log:' + type: note + depends_true: enabled + required: false + description: The Value Log (vlog) file in your config folder is used to ensure data integrity in the database. It can get large, so you can adjust the maximum size. After quitting jfa-go, the file can be deleted safely without data loss. + style: info + - setting: value_log_size + name: Database max vlog size (MiB) + requires_restart: true + type: number + value: 1024 + description: Max size for the database's value log. Lower values may reduce performance. - setting: debug_log_emails name: 'Debug Storage Logging: Emails' requires_restart: true diff --git a/storage.go b/storage.go index 0a4e5cb..f9e503d 100644 --- a/storage.go +++ b/storage.go @@ -175,6 +175,7 @@ func generateLogActions(c *ini.File) map[string]DebugLogAction { func (app *appContext) ConnectDB() { opts := badgerhold.DefaultOptions + opts.Options.ValueLogFileSize = app.config.Section("advanced").Key("value_log_size").MustInt64(1024) * 1024 opts.Dir = app.storage.db_path opts.ValueDir = app.storage.db_path db, err := badgerhold.Open(opts)