summaryrefslogtreecommitdiffstats
path: root/lib/App/BorgRestore
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-12-04 12:01:01 +0100
committerFlorian Pritz <bluewind@xinu.at>2017-12-04 12:01:01 +0100
commitff87476fe745ecafcafe779241469b5617831c27 (patch)
treef942062e21929dfb23c4746ce36878853ee84547 /lib/App/BorgRestore
parenta86bb1b8ffdb822187ce4841d72f0698e1446dd7 (diff)
downloadApp-BorgRestore-ff87476fe745ecafcafe779241469b5617831c27.tar.gz
App-BorgRestore-ff87476fe745ecafcafe779241469b5617831c27.tar.xz
Warn if sqlite cache is full
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/App/BorgRestore')
-rw-r--r--lib/App/BorgRestore/DB.pm11
1 files changed, 11 insertions, 0 deletions
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");
}