diff options
author | Florian Pritz <bluewind@xinu.at> | 2017-12-04 12:01:01 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2017-12-04 12:01:01 +0100 |
commit | ff87476fe745ecafcafe779241469b5617831c27 (patch) | |
tree | f942062e21929dfb23c4746ce36878853ee84547 /lib | |
parent | a86bb1b8ffdb822187ce4841d72f0698e1446dd7 (diff) | |
download | App-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')
-rw-r--r-- | lib/App/BorgRestore.pm | 3 | ||||
-rw-r--r-- | lib/App/BorgRestore/DB.pm | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index b26c88d..828838c 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -438,6 +438,7 @@ method _handle_removed_archives($borg_archives) { $self->{db}->remove_archive($archive); $self->{db}->commit; $self->{db}->vacuum; + $self->{db}->verify_cache_fill_rate_ok(); } my $end = Time::HiRes::gettimeofday(); @@ -476,6 +477,7 @@ method _handle_added_archives($borg_archives) { $self->_save_node($archive_id, undef, $lookuptable); $self->{db}->commit; $self->{db}->vacuum; + $self->{db}->verify_cache_fill_rate_ok(); my $end = Time::HiRes::gettimeofday(); $log->debugf("Adding archive finished after: %.5fs (parsing borg output took %.5fs)", $end - $start, $borg_time - $start); @@ -519,6 +521,7 @@ method update_cache() { $self->_handle_added_archives($borg_archives); $log->debugf("DB contains information for %d archives in %d rows", scalar(@{$self->{db}->get_archive_names()}), $self->{db}->get_archive_row_count()); + $self->{db}->verify_cache_fill_rate_ok(); } 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"); } |