From ff246669798bfb35610215ca2f8f0559752f1020 Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Sat, 18 May 2024 08:18:36 +0200 Subject: [PATCH 1/4] debug: fix the --dump node names --- contrib/munin-node-debug | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/munin-node-debug b/contrib/munin-node-debug index eecb78344..7f139bb3c 100755 --- a/contrib/munin-node-debug +++ b/contrib/munin-node-debug @@ -97,8 +97,8 @@ if ($dump_config) { for (my $i = 0; $i < $nb_servers; $i++) { my $port = $starting_port + $i; for (my $p = 0; $p < $nb_servers_per_port; $p++) { - my $hostname = get_hostname($i, $p); - my $group = get_group($i, $p); + my $hostname = get_hostname($port, $p); + my $group = get_group($port, $p); print "[$group;$hostname]\n"; print " address 127.0.0.1\n"; print " port $port\n"; From a8b1f4f09ea15a65510a4424a5e68cd637b2508c Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Sat, 18 May 2024 08:19:30 +0200 Subject: [PATCH 2/4] m/u: adding logging to get_dbh() --- lib/Munin/Master/Update.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Munin/Master/Update.pm b/lib/Munin/Master/Update.pm index 8f3c62f1c..fc85502cd 100644 --- a/lib/Munin/Master/Update.pm +++ b/lib/Munin/Master/Update.pm @@ -84,18 +84,21 @@ sub get_dbh { my $dbh = DBI->connect("dbi:$db_driver:dbname=$datafilename", $db_user, $db_passwd, \%db_args) or die $DBI::errstr; - DEBUG 'get_dbh: $dbh->{Driver}->{Name} = ' . $dbh->{Driver}->{Name} . ($is_read_only ? "(ro)" : "(rw)"); + 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"; 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"; + DEBUG "get_dbh: PRAGMA main.synchronous=$db_synchronous_mode;" if $db_driver eq "SQLite"; # AutoCommit when readonly is a no-op anyway $dbh->{AutoCommit} = 0; $dbh->{AutoCommit} = 1 if $is_read_only; + DEBUG "get_dbh: {AutoCommit} = " . $dbh->{AutoCommit}; # Plainly returns it, but do *not* put it in $self, as it will let Perl # do its GC properly and closing it when out of scope. From e9a2559cb2fa417a750e729595e398f0cc2cb752 Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Sat, 18 May 2024 08:20:12 +0200 Subject: [PATCH 3/4] m/u: adding a config option for autocommit --- lib/Munin/Master/Update.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Munin/Master/Update.pm b/lib/Munin/Master/Update.pm index fc85502cd..fe6a60240 100644 --- a/lib/Munin/Master/Update.pm +++ b/lib/Munin/Master/Update.pm @@ -96,7 +96,7 @@ sub get_dbh { DEBUG "get_dbh: PRAGMA main.synchronous=$db_synchronous_mode;" if $db_driver eq "SQLite"; # AutoCommit when readonly is a no-op anyway - $dbh->{AutoCommit} = 0; + $dbh->{AutoCommit} = $ENV{MUNIN_DB_AUTOCOMMIT} || $config->{db_autocommit} || 0; $dbh->{AutoCommit} = 1 if $is_read_only; DEBUG "get_dbh: {AutoCommit} = " . $dbh->{AutoCommit}; From f2df5c1706f81a803d4e74e4bf691c4189429ae9 Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Sat, 18 May 2024 08:24:31 +0200 Subject: [PATCH 4/4] 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";