user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] xapcmd: delay over->check_inodes trigger
@ 2020-07-05 21:51 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2020-07-05 21:51 UTC (permalink / raw)
  To: meta

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}) {

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-05 21:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-05 21:51 [PATCH] xapcmd: delay over->check_inodes trigger Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).