about summary refs log tree commit homepage
path: root/lib/PublicInbox/Xapcmd.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-07-05 21:51:31 +0000
committerEric Wong <e@yhbt.net>2020-07-14 09:14:12 +0000
commit2a5ffae959ebe49dbfbff809db1aa798ceae4228 (patch)
tree06704962df6ab159b9cc7f72a20772d2df0e7238 /lib/PublicInbox/Xapcmd.pm
parentd78efbd2f3d973477099261e3c75bf4852473b77 (diff)
downloadpublic-inbox-2a5ffae959ebe49dbfbff809db1aa798ceae4228.tar.gz
xapcmd: delay over->check_inodes trigger
We must not trigger wakeups on InboxIdle users until after we've
renamed all files into place.  Otherwise, the InboxIdle caller
may just reopen the old (soon-to-be-unlinked) file.

This fixes occasional test failures in t/nntpd.t

Fixes: f977826a17f8735e ("lock: reduce inotify wakeups")
Diffstat (limited to 'lib/PublicInbox/Xapcmd.pm')
-rw-r--r--lib/PublicInbox/Xapcmd.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index 78414041..a57fa559 100644
--- a/lib/PublicInbox/Xapcmd.pm
+++ b/lib/PublicInbox/Xapcmd.pm
@@ -23,6 +23,7 @@ sub commit_changes ($$$$) {
 
         $SIG{INT} or die 'BUG: $SIG{INT} not handled';
         my @old_shard;
+        my $over_chg;
 
         while (my ($old, $newdir) = each %$tmp) {
                 next if $old eq ''; # no invalid paths
@@ -39,7 +40,7 @@ sub commit_changes ($$$$) {
                         my $tmp_over = "$new/over.sqlite3";
                         $over->connect->sqlite_backup_to_file($tmp_over);
                         $over = undef;
-                        syswrite($im->{lockfh}, '.'); # trigger ->check_inodes
+                        $over_chg = 1;
                 }
 
                 if (!defined($new)) { # culled shard
@@ -60,6 +61,10 @@ sub commit_changes ($$$$) {
                                 die "failed to remove $prev: $!\n";
                 }
         }
+
+        # trigger ->check_inodes in read-only daemons
+        syswrite($im->{lockfh}, '.') if $over_chg;
+
         remove_tree(@old_shard);
         $tmp = undef;
         if (!$opt->{-coarse_lock}) {