about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-02 10:17:56 +0000
committerEric Wong <e@80x24.org>2021-09-02 10:18:36 +0000
commit44917fdd24a8bec1125caa21949476f97d8658d4 (patch)
tree7bec8992780e589bca44b111d06452f1a7c7ae4c /lib
parent3f27381a79782be136ae8d27c8f585edbbc6f6bf (diff)
downloadpublic-inbox-44917fdd24a8bec1125caa21949476f97d8658d4.tar.gz
For lei-index to work in parallel with MUA access and upcoming
inotify-based updates, mail_sync.sqlite3 needs to always be
up-to-date to read-only worker processes (ahead of everything
else).  So rely on the default auto-commit behavior and hope
SQLite WAL can reduce some of the overheads involved with
writes.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/LeiMailSync.pm14
-rw-r--r--lib/PublicInbox/LeiStore.pm10
2 files changed, 4 insertions, 20 deletions
diff --git a/lib/PublicInbox/LeiMailSync.pm b/lib/PublicInbox/LeiMailSync.pm
index f8834a27..5a10c127 100644
--- a/lib/PublicInbox/LeiMailSync.pm
+++ b/lib/PublicInbox/LeiMailSync.pm
@@ -32,9 +32,7 @@ sub new {
         bless { filename => $f, fmap => {} }, $cls;
 }
 
-sub lms_commit { delete($_[0]->{dbh})->commit }
-
-sub lms_begin { ($_[0]->{dbh} //= dbh_new($_[0], 1))->begin_work };
+sub lms_write_prepare { ($_[0]->{dbh} //= dbh_new($_[0], 1)) };
 
 sub create_tables {
         my ($dbh) = @_;
@@ -468,14 +466,4 @@ sub imap_oid {
         $oidbin ? unpack('H*', $oidbin) : undef;
 }
 
-# FIXED? something with "lei <up|q>" is causing uncommitted transaction
-# TODO: remove soon
-sub DESTROY {
-        my ($self) = @_;
-        my $dbh = delete($self->{dbh}) or return;
-        return if $dbh->{ReadOnly};
-        undef $dbh;
-        warn "BUG $$ $0 $self {dbh} OPEN ppid=".getppid.' '.Carp::longmess();
-}
-
 1;
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm
index ab39043e..6c557d99 100644
--- a/lib/PublicInbox/LeiStore.pm
+++ b/lib/PublicInbox/LeiStore.pm
@@ -202,7 +202,7 @@ sub _lms_rw ($) {
                 require PublicInbox::LeiMailSync;
                 my $f = "$self->{priv_eidx}->{topdir}/mail_sync.sqlite3";
                 my $lms = PublicInbox::LeiMailSync->new($f);
-                $lms->lms_begin;
+                $lms->lms_write_prepare;
                 $lms;
         };
 }
@@ -450,9 +450,7 @@ sub checkpoint {
         if (my $im = $self->{im}) {
                 $wait ? $im->barrier : $im->checkpoint;
         }
-        if (my $lms = delete $self->{lms}) {
-                $lms->lms_commit;
-        }
+        delete $self->{lms};
         $self->{priv_eidx}->checkpoint($wait);
 }
 
@@ -481,9 +479,7 @@ sub done {
                         warn $err;
                 }
         }
-        if (my $lms = delete $self->{lms}) {
-                $lms->lms_commit;
-        }
+        delete $self->{lms};
         $self->{priv_eidx}->done; # V2Writable::done
         xchg_stderr($self);
         die $err if $err;