about summary refs log tree commit homepage
path: root/lib/PublicInbox/V2Writable.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-12 22:44:58 +0000
committerEric Wong <e@80x24.org>2021-10-13 00:41:23 +0000
commit340b740e5caa8337b91b4f490ff60c1084931be6 (patch)
treedfd622bc5963fbaae4dcc5394c75684c14933eca /lib/PublicInbox/V2Writable.pm
parent9a5be3eef9b5e3bf02b40080a83b18be6e87048f (diff)
downloadpublic-inbox-340b740e5caa8337b91b4f490ff60c1084931be6.tar.gz
This covers v1 inboxes, as well.  We also guard the execution
since "PRAGMA optimize" was only introduced in SQLite 3.18.0
(2017-03-30)
Diffstat (limited to 'lib/PublicInbox/V2Writable.pm')
-rw-r--r--lib/PublicInbox/V2Writable.pm16
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index efcc1fc2..3914383c 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -547,11 +547,11 @@ sub checkpoint ($;$) {
         }
         my $shards = $self->{idx_shards};
         if ($shards) {
-                my $mm = $self->{mm};
-                my $dbh = $mm->{dbh} if $mm;
+                my $dbh = $self->{mm}->{dbh} if $self->{mm};
 
                 # SQLite msgmap data is second in importance
                 $dbh->commit if $dbh;
+                eval { $dbh->do('PRAGMA optimize') };
 
                 # SQLite overview is third
                 $self->{oidx}->commit_lazy;
@@ -620,16 +620,10 @@ sub done {
                 my $m = $err ? 'rollback' : 'commit';
                 eval { $mm->{dbh}->$m };
                 $err .= "msgmap $m: $@\n" if $@;
-                eval { $mm->{dbh}->do('PRAGMA optimize') };
-                $err .= "msgmap optimize: $@\n" if $@;
         }
-        if ($self->{oidx} && $self->{oidx}->{dbh}) {
-                if ($err) {
-                        eval { $self->{oidx}->rollback_lazy };
-                        $err .= "overview rollback: $@\n" if $@;
-                }
-                eval { $self->{oidx}->{dbh}->do('PRAGMA optimize') };
-                $err .= "overview optimize: $@\n" if $@;
+        if ($self->{oidx} && $self->{oidx}->{dbh} && $err) {
+                eval { $self->{oidx}->rollback_lazy };
+                $err .= "overview rollback: $@\n" if $@;
         }
 
         my $shards = delete $self->{idx_shards};