From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EA80B1F5AE for ; Sun, 5 Jul 2020 21:51:31 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] xapcmd: delay over->check_inodes trigger Date: Sun, 5 Jul 2020 21:51:31 +0000 Message-Id: <20200705215131.22450-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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") --- lib/PublicInbox/Xapcmd.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm index 784140416..a57fa5597 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}) {