From ff87476fe745ecafcafe779241469b5617831c27 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 4 Dec 2017 12:01:01 +0100 Subject: Warn if sqlite cache is full Signed-off-by: Florian Pritz --- lib/App/BorgRestore/DB.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/App/BorgRestore') diff --git a/lib/App/BorgRestore/DB.pm b/lib/App/BorgRestore/DB.pm index 0bc5214..3fddbf1 100644 --- a/lib/App/BorgRestore/DB.pm +++ b/lib/App/BorgRestore/DB.pm @@ -9,6 +9,7 @@ use autodie; use DBI; use Function::Parameters; use Log::Any qw($log); +use Number::Bytes::Human qw(format_bytes); use Path::Tiny; =encoding utf-8 @@ -36,6 +37,7 @@ method new($class: $db_path, $cache_size) { } else { $self->_open_db($db_path, $cache_size); } + $self->{cache_size} = $cache_size; return $self; } @@ -166,6 +168,15 @@ method commit() { $self->{dbh}->commit(); } +method verify_cache_fill_rate_ok() { + my $used = $self->{dbh}->sqlite_db_status()->{cache_used}->{current}; + $log->debugf("sqlite page cache usage: %s", format_bytes($used, si=>1)); + if ($used > $self->{cache_size} * 1024 * 0.95) { + $log->warnf("sqlite cache usage is %s of %s", format_bytes($used, si=>1), format_bytes($self->{cache_size} * 1024, si => 1)); + $log->warn("Consider increasing the sqlite cache (see documentation of App::BorgRestore::Settings)"); + } +} + method vacuum() { $self->{dbh}->do("vacuum"); } -- cgit v1.2.3-24-g4f1b