Re: [Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`?
"J. Lewis Muir"writes: > On 11/12, Austin Clements wrote: >> Quoth David Bremner on Nov 04 at 1:26 pm: >> > I agree it looks like a race condition. inotify sounds a bit >> > overcomplicated and perhaps non-portable? It should probably just >> > tolerate disappearing files better, consider that a warning. >> >> Inotify really *is* the solution. > > I don't see how inotify can be the solution unless the idea is to make > Notmuch run on Linux only. Inotify is a Linux kernel API. Some other > OSes have their own native file event notification facilities, but not > all of them have it, and most (if not all) only support file event > notifications for certain file systems and not for others (e.g., not for > NFS). Yeah, it's worth saying that, even if I think Austin knows. I was thinking that an alternative approach might be to have either notmuch new or notmuch insert take a file name on the command line, and let the user call it via what ever kind of directory watcher utility works on their system. d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`?
On 11/12, Austin Clements wrote: > Quoth David Bremner on Nov 04 at 1:26 pm: > > I agree it looks like a race condition. inotify sounds a bit > > overcomplicated and perhaps non-portable? It should probably just > > tolerate disappearing files better, consider that a warning. > > Inotify really *is* the solution. I don't see how inotify can be the solution unless the idea is to make Notmuch run on Linux only. Inotify is a Linux kernel API. Some other OSes have their own native file event notification facilities, but not all of them have it, and most (if not all) only support file event notifications for certain file systems and not for others (e.g., not for NFS). Regards, Lewis ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`?
Quoth David Bremner on Nov 04 at 1:26 pm: > > Paul Wise wrote: > > > Last night I got this error from my `notmuch new --quiet` cron job. The > > file that the error message complains about is now in the cur directory > > of the maildir at the following path. > > > > /path/to/mail/cur/1478190211.H80553P18378.chianamo:2, > > > > I wonder if this some kind of race condition in `notmuch new` processing. > > Perhaps it should be using inotify to find out about file movements? > > > > Unexpected error with file > > /path/to/mail/new/1478190211.H80553P18378.chianamo > > add_file: Something went wrong trying to read or write a file > > Error opening /path/to/mail/new/1478190211.H80553P18378.chianamo: No such > > file or directory > > Note: A fatal error was encountered: Something went wrong trying to read or > > write a file > > I agree it looks like a race condition. inotify sounds a bit > overcomplicated and perhaps non-portable? It should probably just > tolerate disappearing files better, consider that a warning. Inotify really *is* the solution. This is a symptom of a much bigger problem: scandir makes no guarantees in the presence of concurrent directory modification. If you delete or rename a file while notmuch new is running, it may think *completely unrelated* files in the same directory were also deleted. Even if scandir were atomic, if you move a mail from one directory to another between notmuch scanning the destination directory and notmuch scanning the source directory, it'll think the mail has been deleted and potentially remove it from the DB. The "recommended" solution is to scandir is to start an inotify watch before the scan and redo (or update) the scan if there are any changes. For notmuch, it would make sense to extend that to watching all directories to make sure it can catch renames during the scan. A possible alternative, though I haven't worked out the details, might be to keep a close eye on the directory mtimes. Roughly, for each directory, check the mtime before scanning, wait if necessary until the mtime != the current time, do the scan and process the files optimistically. Once all directories are processed, re-check all of the mtimes and if any have changed, do something like starting over but hopefully more intelligent. ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`?
On Fri, 2016-11-04 at 20:47 +0200, Jani Nikula wrote: > Do you have some other software modifying your mail store while > you're running notmuch new? The folder in question has my laptop's exim4 service writing to it when my cron jobs generate email. On Fri, 2016-11-04 at 13:26 -0300, David Bremner wrote: > inotify sounds a bit overcomplicated and perhaps non-portable? There are similar APIs on non-Linux OSes but there is indeed no common API or library to abstract away this sort of feature AFAIK. > It should probably just tolerate disappearing files better, consider > that a warning. That sounds like the correct solution indeed. Probably if the code notices that a file disappeared, it should also rescan the nearby folders to see if the file was moved instead of deleted. > As a workaround, if you can replace background use of notmuch-new > with notmuch-insert (and I understand this doesn't work for > everyone), you will eliminate this kind of race condition. Hmm, I don't think that will work for me. -- bye, pabs https://wiki.debian.org/PaulWise signature.asc Description: This is a digitally signed message part ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`?
On Fri, 04 Nov 2016, David Bremnerwrote: > I wonder if this some kind of race condition in `notmuch new` > processing. Do you have some other software modifying your mail store while you're running notmuch new? BR, Jani. ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`?
Paul Wise wrote: > Last night I got this error from my `notmuch new --quiet` cron job. The > file that the error message complains about is now in the cur directory > of the maildir at the following path. > > /path/to/mail/cur/1478190211.H80553P18378.chianamo:2, > > I wonder if this some kind of race condition in `notmuch new` processing. > Perhaps it should be using inotify to find out about file movements? > > Unexpected error with file /path/to/mail/new/1478190211.H80553P18378.chianamo > add_file: Something went wrong trying to read or write a file > Error opening /path/to/mail/new/1478190211.H80553P18378.chianamo: No such > file or directory > Note: A fatal error was encountered: Something went wrong trying to read or > write a file I agree it looks like a race condition. inotify sounds a bit overcomplicated and perhaps non-portable? It should probably just tolerate disappearing files better, consider that a warning. As a workaround, if you can replace background use of notmuch-new with notmuch-insert (and I understand this doesn't work for everyone), you will eliminate this kind of race condition. d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[Paul Wise] Bug#843127: notmuch: race condition in `notmuch new`?
--- Begin Message --- Package: notmuch Version: 0.23.1-1 Severity: normal Last night I got this error from my `notmuch new --quiet` cron job. The file that the error message complains about is now in the cur directory of the maildir at the following path. /path/to/mail/cur/1478190211.H80553P18378.chianamo:2, I wonder if this some kind of race condition in `notmuch new` processing. Perhaps it should be using inotify to find out about file movements? Unexpected error with file /path/to/mail/new/1478190211.H80553P18378.chianamo add_file: Something went wrong trying to read or write a file Error opening /path/to/mail/new/1478190211.H80553P18378.chianamo: No such file or directory Note: A fatal error was encountered: Something went wrong trying to read or write a file -- System Information: Debian Release: stretch/sid APT prefers testing-debug APT policy: (900, 'testing-debug'), (900, 'testing'), (800, 'unstable-debug'), (800, 'unstable'), (790, 'buildd-unstable'), (700, 'experimental-debug'), (700, 'experimental'), (690, 'buildd-experimental') Architecture: amd64 (x86_64) Kernel: Linux 4.7.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_AU.utf8, LC_CTYPE=en_AU.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages notmuch depends on: ii libc6 2.24-5 ii libglib2.0-02.50.1-1 ii libgmime-2.6-0 2.6.20-8 ii libnotmuch4 0.23.1-1 ii libtalloc2 2.1.8-1 ii zlib1g 1:1.2.8.dfsg-2+b3 Versions of packages notmuch recommends: ii alot 0.3.6-1 ii gnupg-agent2.1.15-4 pn gpgsm ii notmuch-emacs 0.23.1-1 ii notmuch-mutt 0.23.1-1 notmuch suggests no packages. -- no debconf information -- bye, pabs https://wiki.debian.org/PaulWise signature.asc Description: This is a digitally signed message part --- End Message --- ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch