Bug 287625 - ItemDeleteJob error, causing akonadi<-->akonadi_mixedmaildir_resource communication to stall
Summary: ItemDeleteJob error, causing akonadi<-->akonadi_mixedmaildir_resource communi...
Status: RESOLVED FIXED
Alias: None
Product: kdepim
Classification: Applications
Component: libkdepim (show other bugs)
Version: 4.7
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-26 17:18 UTC by Ahti Heinla
Modified: 2011-11-30 15:11 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Workaround in RetrieveItemsJob (842 bytes, patch)
2011-11-26 17:20 UTC, Ahti Heinla
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ahti Heinla 2011-11-26 17:18:02 UTC
Version:           4.7 (using KDE 4.7.3) 
OS:                Linux

Akonadi::ItemDeleteJob constructors expect to get either a *non-empty* list of items to be deleted, or a valid collection to be deleted; it does not tolerate an *empty* list of items to be deleted. However, RetrieveItemsJob::Private::storeListResult() in akonadi_mixedmaildir_resource sometimes gives it just that: an empty mServerItemsByRemoteId.values() list. This causes ItemDeleteJob to report error "Invalid collection specified", and Akonadi<-->akonadi_mixedmaildir_resource communication stalls (akonadiconsole debugger shows a transaction BEGIN followed by nothing), and this in turn causes all kinds of major problems in KMail (KMail becomes out of sync with akonadi_mixedmaildir_resource, cannot even open e-mail messages).

Reproducible: Sometimes

Steps to Reproduce:
1. akonadictl start
2. akonadiconsole
3. In akonadiconsole "Browser" tab, click "Synchronize Folder" on any KMail Folder

Actual Results:  
In akonadiconsole "Agents" tab, status of "KMail Folders" should be "Synchronizing email folder <XYZ>" for some time, then become "Ready" again

Expected Results:  
In akonadiconsole "Agents" tab, status of "KMail Folders" goes to "Synchronizing email folder <XYZ>" forever (at least hours, even with an empty folder)
Comment 1 Ahti Heinla 2011-11-26 17:20:16 UTC
Created attachment 66099 [details]
Workaround in RetrieveItemsJob

I'm not sure if this bug should be fixed in RetrieveItemsJob or in ItemDeleteJob. Here is a patch that fixes it in RetrieveItemsJob.
Comment 2 Allen Winter 2011-11-29 03:19:16 UTC
Git commit aedcddf94b1b10b929d244d1063cb61c2c467105 by Allen Winter.
Committed on 29/11/2011 at 04:16.
Pushed by winterz into branch 'master'.

in Private::storeListResult(), don't try to create a delete job
for an empty list of items.  probably means that the ItemDeleteJob
class should assert on such cases so we find other errors like this.

Patch by Ahti, thanks!

BUG: 287625
MERGE: 4.7

M  +34   -32   resources/mixedmaildir/retrieveitemsjob.cpp

http://commits.kde.org/kdepim-runtime/aedcddf94b1b10b929d244d1063cb61c2c467105
Comment 3 Allen Winter 2011-11-29 22:57:44 UTC
Git commit 18984cacbd7afda8f86d01bff26083bec4b06b57 by Allen Winter.
Committed on 29/11/2011 at 04:16.
Pushed by winterz into branch 'KDE/4.7'.

in Private::storeListResult(), don't try to create a delete job
for an empty list of items.  probably means that the ItemDeleteJob
class should assert on such cases so we find other errors like this.

Patch by Ahti, thanks!

BUG: 287625
MERGE: 4.7
(cherry picked from commit aedcddf94b1b10b929d244d1063cb61c2c467105)

M  +34   -32   resources/mixedmaildir/retrieveitemsjob.cpp

http://commits.kde.org/kdepim-runtime/18984cacbd7afda8f86d01bff26083bec4b06b57
Comment 4 Ahti Heinla 2011-11-30 15:11:02 UTC
A general comment: as a software architect unfamiliar with KMail/Akonadi inner workings, I must say am shocked that Akonadi protocol is designed to be so brittle: that such a small bug in Job implementation can stall the whole communication with an Akonadi resource.

As I understand, stalling communication is much worse than crashing, as it pushes Akonadi and its resource more and more out of sync and can perhaps result in data loss. As I understand, I received a bunch of mails via POP3 in KMail, read them, moved between folders etc, with "KMail Folders" resource totally out the loop for several hours.