From 7ff6a866f60e4b5a61edbb00bb1230af5a9215db Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Sat, 18 May 2024 08:24:31 +0200 Subject: [PATCH] m/u: SQLite journaling defaults if not explicit We do leverage the SQLite defaults if we don't override it explicitely in munin config. This ensure that the safest default for the current platform is used as the SQLite package should be trusted on it. --- lib/Munin/Master/Update.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Munin/Master/Update.pm b/lib/Munin/Master/Update.pm index fe6a60240..ed249cced 100644 --- a/lib/Munin/Master/Update.pm +++ b/lib/Munin/Master/Update.pm @@ -87,9 +87,13 @@ sub get_dbh { INFO 'get_dbh: $dbh->{Driver}->{Name} = ' . $dbh->{Driver}->{Name} . ($is_read_only ? "(ro)" : "(rw)"); # Sets some session vars - my $db_journal_mode = $ENV{MUNIN_DB_JOURNAL_MODE} || $config->{db_journal_mode} || "TRUNCATE"; - $dbh->do("PRAGMA journal_mode=$db_journal_mode;") if $db_driver eq "SQLite"; - DEBUG "get_dbh: PRAGMA journal_mode=$db_journal_mode;" if $db_driver eq "SQLite"; + + # db_journal_mode is only set explicitely. Otherwise use the platform SQLite default + my $db_journal_mode = $ENV{MUNIN_DB_JOURNAL_MODE} || $config->{db_journal_mode}; + if ($db_journal_mode) { + $dbh->do("PRAGMA journal_mode=$db_journal_mode;") if $db_driver eq "SQLite"; + DEBUG "get_dbh: PRAGMA journal_mode=$db_journal_mode;" if $db_driver eq "SQLite"; + } my $db_synchronous_mode = $ENV{MUNIN_DB_SYNCHRONOUS_MODE} || $config->{db_synchronous_mode} || "OFF"; $dbh->do("PRAGMA main.synchronous=$db_synchronous_mode;") if $db_driver eq "SQLite";