about summary refs log tree commit homepage
path: root/lib/PublicInbox/LEI.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-04-21 11:59:06 +0000
committerEric Wong <e@80x24.org>2022-04-22 03:05:56 +0000
commit7e4bd71efcf3bf61216ec1a7577e33be5f95b8a9 (patch)
tree25569363d09dd1d047a2e8e158c1a5ccfd1a9e1d /lib/PublicInbox/LEI.pm
parentd362af89d8019ff12d3550c83de2c3aa5d9f095b (diff)
downloadpublic-inbox-7e4bd71efcf3bf61216ec1a7577e33be5f95b8a9.tar.gz
This change prevents lingering shard and git-fast-import
processes from remaining after interrupted "lei import" (and
similar).  It also reduces the likelyhood of data-loss in case
of subsequent abnormal termination of the daemon.

I think this is the least surprising way to handle users
prematurely aborting imports or other similar operations which
write to lei/store and will result in reduced bandwidth waste
for users with intermittent connections.  This is because the
lei/store processes may be shared by parallel "lei import"
callers, and commits done by any "lei import" caller will
inevitably trigger writes for all of them.
Diffstat (limited to 'lib/PublicInbox/LEI.pm')
-rw-r--r--lib/PublicInbox/LEI.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 4bd9183e..93b4ea03 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -660,6 +660,7 @@ sub wait_wq_events {
         for my $wq (grep(defined, @$lei{qw(ikw pmd)})) { # auxiliary WQs
                 $wq->wq_close;
         }
+        $wq1->{lei_sock} = $lei->{sock} if $wq1;
         $op_c->{ops} = $ops;
 }
 
@@ -1405,9 +1406,11 @@ sub fchdir {
 }
 
 sub wq_eof { # EOF callback for main daemon
-        my ($lei) = @_;
+        my ($lei, $wq_fld) = @_;
         local $current_lei = $lei;
-        delete $lei->{wq1} // return $lei->fail; # already failed
+        my $wq = delete $lei->{$wq_fld // 'wq1'};
+        $lei->sto_done_request($wq);
+        $wq // $lei->fail; # already failed
 }
 
 sub watch_state_ok ($) {
@@ -1514,8 +1517,10 @@ sub lms {
 }
 
 sub sto_done_request {
-        my ($lei, $sock) = @_;
+        my ($lei, $wq) = @_;
+        return unless $lei->{sto};
         local $current_lei = $lei;
+        my $sock = $wq ? $wq->{lei_sock} : undef;
         eval {
                 if ($sock //= $lei->{sock}) { # issue, async wait
                         $lei->{sto}->wq_io_do('done', [ $sock ]);