dovecot: IMAP(uid): fstat() failed with file /home/uid/mail/.imap/INBOX/dovecot.index.log: Stale NFS file handle
(a) why can't it just close the file and re-open ?
NFS has issues with files that are open on one client, and get deleted on another. UNIX systems require that files don't disappear while they are in use, but NFS is stateless and it simply can't know when a file is in use. The result is the 'stale NFS handle' kludge, which also prevents a simple close-and-open. Don't use index files on NFS disks.
First, the file did not disappear - the NFS is flaky under high load, that's all. Closing and re-opening the file would probably fix the issue, at least after the traffic spike.
Second, these are files that are intended for dovecots internal use only. If the NFS filehandle goes stale, it's anyway highly unlikely that someone else has deleted them, and dovecot should know that - IMHO it should at least try to recover.
Third, I'm perfectly willing to put the index files on a local disk, but I need dovecot to autodetect the rest of the mail environment, unless I want to define it completely for each user individually, and apparently dovecot does not let me do that(?).
From the (few) answers I got so far, it seems that it is in fact impossible to specify 'default_mail_env = INDEX=/var/spool/mail/INDEX/%u', so would anybody know where in the sources the root directory for the indexes is set, such that I can patch the code?