I was looking at a mail folder and I noted that a file in the inbox had a total of 11 hard links to it: ? # exa -lH cur/1564249738.M167990P53982.mail.covisp.net,S=8572,W=8738:2,Sgl .rw------- 11 8.6k vpopmail 19 Jul 19:59 cur/1564249738.M167990P53982.mail.covisp.net,S=8572,W=8738:2,Sgl ? # find . -samefile cur/1564249738.M167990P53982.mail.covisp.net,S=8572,W=8738:2,Sgl [6:59] [/usr/local/virtual/kreme at kreme.com/Maildir] ./.Junk/cur/1564253637.M808919P50422.mail.covisp.net,S=8572,W=8738:2,bc ./.Junk/cur/1564253637.M808920P50422.mail.covisp.net,S=8572,W=8738:2,bc ./.Junk/cur/1564253723.M977674P50422.mail.covisp.net,S=8572,W=8738:2,bc ./.Junk/cur/1564253723.M977675P50422.mail.covisp.net,S=8572,W=8738:2,bc ./.Junk/cur/1564253723.M977676P50422.mail.covisp.net,S=8572,W=8738:2,bc ./.Junk/cur/1563587951.M591499P47868.mail.covisp.net,S=8572,W=8738:2, ./.Junk/cur/1564851795.M381461P10380.mail.covisp.net,S=8572,W=8738:2,bc ./.Junk/cur/1564851795.M381462P10380.mail.covisp.net,S=8572,W=8738:2,bc ./.Junk/cur/1564852369.M760020P10380.mail.covisp.net,S=8572,W=8738:2,bc ./.Trash/cur/1563587951.M591499P47868.mail.covisp.net,S=8572,W=8738:2,S ./cur/1564249738.M167990P53982.mail.covisp.net,S=8572,W=8738:2,Sgl A bit of background: a few weeks ago I had thousands of files in the mail store that had hundreds of links, and I got that all cleaned up through juggling some grep and awk to delete all but one of the linked files. I figured this was caused by something I?d done when I moved local users into being virtual users and eliminated pam authentication in favor of sql. But this gives me pause. I think it?s normal for a file in the INBOX that is marked as junk or as deleted to have a single hard link (or at least it is since the default was set to maildir_copy_with_hardlinks), but 11? And when do these hard links get cleaned off? If I delete the trashed and junked messages, when does dovecot go through and removed the linked files in the cur/ folder? (It?s not immediate, I trashed those copies in Junk and Trash and the original file is still in the cur folder) -- There is nothing so stupid that some person somewhere will not, with earnestness, say it.
On 16 Aug 19, at 07:33 , @lbutlr <kremels at kreme.com> wrote:> I was looking at a mail folder and I noted that a file in the inbox had a total of 11 hard links to it:Ack. I checked the junk folder and there are 379 files in there with 379 links! Since they were all in jink I just deleted them all, but that cannot possibly be desired behavior. What do I check here? -- Wonderful girl! Either I'm going to kill her or I'm beginning to like her.
On 17 Aug 2019, at 1.57, @lbutlr via dovecot <dovecot at dovecot.org> wrote:> > On 16 Aug 19, at 07:33 , @lbutlr <kremels at kreme.com> wrote: >> I was looking at a mail folder and I noted that a file in the inbox had a total of 11 hard links to it: > > Ack. I checked the junk folder and there are 379 files in there with 379 links! > > Since they were all in jink I just deleted them all, but that cannot possibly be desired behavior. > > What do I check here?Hard links are created when a mail is copied with the IMAP COPY command. So Dovecot just does what the client asks it to do. Maybe you have some misbehaving IMAP client?
On 16 Aug 19, at 16:57 , @lbutlr <kremels at kreme.com> wrote:> Ack. I checked the junk folder and there are 379 files in there with 379 links!It appears the main culprit is actually the sieve script that is supposed to mark messages moved out of the Junk box as ham. Somehow it was getting itself stuck and creating new hard links over at over. Before I for it under control, I have 240,000 ?messages:? in the inbox, 141 of which were actual messages. I have disabled the sieve script and so far the problem hahasn?t reoccurred, but then the sieve script has been there a long time without issues before, so I suspect there was something else going on. ? # cat report-ham.sieve.disabled require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; if environment :matches "imap.mailbox" "*" { set "mailbox" "${1}"; } if string "${mailbox}" "Trash" { stop; } if environment :matches "imap.user" "*" { set "username" "${1}"; } pipe :copy "sa-learn-ham.sh" [ "${username}" ]; Executed via: plugin { ? imapsieve_mailbox2_before = file:/usr/lib/dovecot/sieve/report-ham.sieve imapsieve_mailbox2_causes = COPY imapsieve_mailbox2_from = Junk imapsieve_mailbox2_name = * ? }