Bug 333035

Summary: Supposable timing problem causes duplicate mails after filtering
Product: [Frameworks and Libraries] Akonadi Reporter: Tobias Leupold <tl>
Component: Mail Filter AgentAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED DUPLICATE    
Severity: normal CC: bugs, dvratil, graham, ht990332, kde.bugzilla.2012, kdenis, pageload, rafaelalcantaraperez, tl, web
Priority: NOR    
Version: 5.1.3   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Tobias Leupold 2014-04-03 17:05:26 UTC
I get a lot of emails from my homepage, each time some spam bot posts a spam guestbook or weblog comment. Sometimes, I get 10 or 20 per hour.

I filter those mails (using kmail) and put them in a separate directory. Most of the time, two copies end up there, sometimes also present as two separate files in the maildir. Sometimes I get two copies, but one of them with empty text. Sometimes, I even get new unread mails in my normal inbox which don't show up, and after reading both copies of the filtered mail, the unread mark disappears. Well, sometimes, the filtering even simply works and I only get one mail in the destination folder ;-)

Anyways, this is very annoying, causing hundreds of duplicate mails here – but the behaviour is inconsistent. Most of the time, I simply get two copies of the moved mails.

What I tried is this: I simply added a "Run command: sleep 0.5" after the "Move into folder …" action. With this added, no more duplicate mails show up when this filter is used.

So I think this is some timing problem that occurs when many mails are handled by the same filter. I hope this helps debugging this … I would really love to see this fixed.

Reproducible: Sometimes
Comment 1 Tobias Leupold 2014-04-05 11:15:35 UTC
Even an additional "sleep 0.1" stops mailfilter from producing duplicates.
Comment 2 Johan Spee 2014-06-16 11:18:58 UTC
Confirmed.

This bug also affects outgoing mail:

*I create a filter 'To John' that sets the identity of the message to, say, 'id_private' if John's address matches the 'to' header. The filter is used on all outgoing mail.
* Result: messages to John are put in 'sent-mail' as expected, but a copy also stays behind in the 'outbox'. What is worse: John receives messages that did not have their identity set to 'id_private' .

Deleting duplicated messages can laso be complicated:

* I sent some messages to myself and (upon reveiving them) they all ended up 'in duplo' in the target mailbox (i.e. the mailbox the filter is supposed to move the message to).
* When I next 'trash' the duplicate messages the trash mailbox only shows one, single copy.
I next empty the 'trash' mailbox and open my inbox: a single copy of the message re-appears in the target mailbox!
* I trash that message and it disappears,  but the trash mailbox remains empty. When I open my inbox it is back again, in the target mailbox.

This is not a recent bug, by the way. I have recently tried Debian testing, openSuse 13.1 and openSure 13.1 + KDE 'current': the bug is in all those installations.
Comment 3 Johan Spee 2014-06-17 17:00:04 UTC
Looks like this problem has been around for years:
https://bugs.kde.org/show_bug.cgi?id=283682
Comment 4 Tobias Leupold 2014-12-08 21:09:34 UTC
*** This bug has been confirmed by popular vote. ***
Comment 5 Denis Kurz 2016-09-24 20:34:55 UTC
This bug has only been reported for versions older than KDEPIM 4.14 (at most akonadi-1.3). Can anyone tell if this bug still present?

If noone confirms this bug for a recent version of akonadi (part of KDE Applications 15.08 or later), it gets closed in about three months.
Comment 6 Graeme Hewson 2016-09-26 14:59:43 UTC
I'm still seeing something like this in 5.1.3.

Sometimes I'll see a message in my inbox that should have been filtered to another folder. The unread count for the target folder is 0. If I open the target folder, the unread count is set to 1, and the same message as in my inbox is present. I then go back to my inbox and manually filter the message (Ctrl+J). Now there are two copies of the message in the target folder.
Comment 7 Graeme Hewson 2016-09-26 15:00:50 UTC
I'm using POP3, I should have said.
Comment 8 Denis Kurz 2016-09-26 18:02:53 UTC
Ok, I think I saw multiple bugs around duplication of mails in the last few days. Probably I should try to organize them... From what I read so far, the problem is probably unrelated to POP3, but thanks for reporting back.
Comment 9 Daniel Vrátil 2017-03-22 00:10:48 UTC

*** This bug has been marked as a duplicate of bug 283682 ***
Comment 10 Pageload 2017-11-27 15:14:50 UTC
I confirm concurrency issue: the bug becomes systematic with an SSD drive (ransom of speed!).

sleep 0.1 solves the problem.