Bug 140443 - dimap mail loss on kmail crash and troubleshoot / rebuild / refresh imap cache
Summary: dimap mail loss on kmail crash and troubleshoot / rebuild / refresh imap cache
Status: RESOLVED WAITINGFORINFO
Alias: None
Product: kmail
Classification: Applications
Component: disconnected IMAP (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR grave with 40 votes (vote)
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-22 16:12 UTC by Chris
Modified: 2010-07-21 21:26 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris 2007-01-22 16:12:38 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Ubuntu Packages

I reported this in Bug 104956 already but it was closed due to its complexititvity:

I now AGAIN lost my hole Mail in my Inbox using kmail 1.9.5 from KDE 3.5.5 (Kubuntu)! 
 
What I did: 
 
1. I deleted several mails - mail by mail - in my Inbox. While deleting a mail KMail suddenly crashed (what it does from time to time when deleting mails also with normal imap). I then got this: 
 
[KCrash handler] 
#6  0xb54f3833 in KMHeaders::msgRemoved () from /usr/lib/libkmailprivate.so 
#7  0xb54fef39 in KMHeaders::qt_invoke () from /usr/lib/libkmailprivate.so 
#8  0xb6fec957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#9  0xb552dfd0 in KMFolder::msgRemoved () from /usr/lib/libkmailprivate.so 
#10 0xb552ec8d in KMFolder::qt_emit () from /usr/lib/libkmailprivate.so 
#11 0xb6fec92b in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#12 0xb554bbd0 in FolderStorage::msgRemoved () 
    from /usr/lib/libkmailprivate.so 
#13 0xb554d06c in FolderStorage::take () from /usr/lib/libkmailprivate.so 
#14 0xb55f4b2c in KMFolderMaildir::take () from /usr/lib/libkmailprivate.so 
#15 0xb55e488b in KMFolderCachedImap::take () from /usr/lib/libkmailprivate.so 
#16 0xb552c88e in KMFolder::take () from /usr/lib/libkmailprivate.so 
#17 0xb55f8685 in KMFolderMaildir::addMsgInternal () 
    from /usr/lib/libkmailprivate.so 
#18 0xb55e4847 in KMFolderCachedImap::addMsg () 
    from /usr/lib/libkmailprivate.so 
#19 0xb554a7a3 in FolderStorage::moveMsg () from /usr/lib/libkmailprivate.so 
#20 0xb552c9c5 in KMFolder::moveMsg () from /usr/lib/libkmailprivate.so 
#21 0xb567755f in KMMoveCommand::execute () from /usr/lib/libkmailprivate.so 
#22 0xb5669949 in KMCommand::slotPostTransfer () 
    from /usr/lib/libkmailprivate.so 
#23 0xb5671386 in KMCommand::qt_invoke () from /usr/lib/libkmailprivate.so 
#24 0xb567166b in KMMenuCommand::qt_invoke () from /usr/lib/libkmailprivate.so 
#25 0xb56716f7 in KMMoveCommand::qt_invoke () from /usr/lib/libkmailprivate.so 
#26 0xb567176b in KMDeleteMsgCommand::qt_invoke () 
    from /usr/lib/libkmailprivate.so 
#27 0xb6fec957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#28 0xb56699de in KMCommand::messagesTransfered () 
    from /usr/lib/libkmailprivate.so 
#29 0xb5672241 in KMCommand::transferSelectedMsgs () 
    from /usr/lib/libkmailprivate.so 
#30 0xb56723a7 in KMCommand::slotStart () from /usr/lib/libkmailprivate.so 
#31 0xb5671398 in KMCommand::qt_invoke () from /usr/lib/libkmailprivate.so 
#32 0xb567166b in KMMenuCommand::qt_invoke () from /usr/lib/libkmailprivate.so 
#33 0xb56716f7 in KMMoveCommand::qt_invoke () from /usr/lib/libkmailprivate.so 
#34 0xb567176b in KMDeleteMsgCommand::qt_invoke () 
    from /usr/lib/libkmailprivate.so 
#35 0xb6fec957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#36 0xb7378f44 in QSignal::signal () from /usr/lib/libqt-mt.so.3 
#37 0xb700c8ea in QSignal::activate () from /usr/lib/libqt-mt.so.3 
#38 0xb7014300 in QSingleShotTimer::event () from /usr/lib/libqt-mt.so.3 
#39 0xb6f83b88 in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3 
#40 0xb6f859b7 in QApplication::notify () from /usr/lib/libqt-mt.so.3 
#41 0xb76acdb2 in KApplication::notify () from /usr/lib/libkdecore.so.4 
#42 0xb6f16389 in QApplication::sendEvent () from /usr/lib/libqt-mt.so.3 
#43 0xb6f765d3 in QEventLoop::activateTimers () from /usr/lib/libqt-mt.so.3 
#44 0xb6f2aec5 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3 
#45 0xb6f9e25e in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3 
#46 0xb6f9e06e in QEventLoop::exec () from /usr/lib/libqt-mt.so.3 
#47 0xb6f85731 in QApplication::exec () from /usr/lib/libqt-mt.so.3 
#48 0x0805ad81 in ?? () 
#49 0xbf8d7a40 in ?? () 
#50 0x00000001 in ?? () 
#51 0x00000001 in ?? () 
#52 0x00000000 in ?? () 
 
2. To be secure I then restarted KMail and selected "Lokalen IMAP Zwischenspeicher aktualisieren" (what means something like "Refresh local IMAP cache"). - Kmail then crashed a second time with this result: 
 
[KCrash handler] 
#6  0xb558a833 in KMHeaders::msgRemoved () from /usr/lib/libkmailprivate.so 
#7  0xb5595f39 in KMHeaders::qt_invoke () from /usr/lib/libkmailprivate.so 
#8  0xb7083957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#9  0xb55c4fd0 in KMFolder::msgRemoved () from /usr/lib/libkmailprivate.so 
#10 0xb55c5c8d in KMFolder::qt_emit () from /usr/lib/libkmailprivate.so 
#11 0xb708392b in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#12 0xb55e2bd0 in FolderStorage::msgRemoved () 
    from /usr/lib/libkmailprivate.so 
#13 0xb55e406c in FolderStorage::take () from /usr/lib/libkmailprivate.so 
#14 0xb568bb2c in KMFolderMaildir::take () from /usr/lib/libkmailprivate.so 
#15 0xb567b88b in KMFolderCachedImap::take () from /usr/lib/libkmailprivate.so 
#16 0xb55c388e in KMFolder::take () from /usr/lib/libkmailprivate.so 
#17 0xb568f685 in KMFolderMaildir::addMsgInternal () 
    from /usr/lib/libkmailprivate.so 
#18 0xb568ffa7 in KMFolderMaildir::addMsg () from /usr/lib/libkmailprivate.so 
#19 0xb55e17a3 in FolderStorage::moveMsg () from /usr/lib/libkmailprivate.so 
#20 0xb55c39c5 in KMFolder::moveMsg () from /usr/lib/libkmailprivate.so 
#21 0xb56103a6 in KMFilterMgr::process () from /usr/lib/libkmailprivate.so 
#22 0xb5582a42 in KMAccount::processNewMsg () from /usr/lib/libkmailprivate.so 
#23 0xb567cca0 in KMFolderCachedImap::addMsgInternal () 
    from /usr/lib/libkmailprivate.so 
#24 0xb574723d in KMail::CachedImapJob::slotGetNextMessage () 
    from /usr/lib/libkmailprivate.so 
#25 0xb5744812 in KMail::CachedImapJob::qt_invoke () 
    from /usr/lib/libkmailprivate.so 
#26 0xb7083957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#27 0xb6b6477e in KIO::Job::result () from /usr/lib/libkio.so.4 
#28 0xb6ba4a8d in KIO::Job::emitResult () from /usr/lib/libkio.so.4 
#29 0xb6bb875e in KIO::SimpleJob::slotFinished () from /usr/lib/libkio.so.4 
#30 0xb6bb8e6d in KIO::TransferJob::slotFinished () from /usr/lib/libkio.so.4 
#31 0xb6ba46ba in KIO::TransferJob::qt_invoke () from /usr/lib/libkio.so.4 
#32 0xb7083957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#33 0xb70843fc in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#34 0xb6b5effc in KIO::SlaveInterface::finished () from /usr/lib/libkio.so.4 
#35 0xb6bc4720 in KIO::SlaveInterface::dispatch () from /usr/lib/libkio.so.4 
#36 0xb6bc275a in KIO::SlaveInterface::dispatch () from /usr/lib/libkio.so.4 
#37 0xb6b7343c in KIO::Slave::gotInput () from /usr/lib/libkio.so.4 
#38 0xb6bb2360 in KIO::Slave::qt_invoke () from /usr/lib/libkio.so.4 
#39 0xb7083957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#40 0xb708426e in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#41 0xb7410cdb in QSocketNotifier::activated () from /usr/lib/libqt-mt.so.3 
#42 0xb70a6516 in QSocketNotifier::event () from /usr/lib/libqt-mt.so.3 
#43 0xb701ab88 in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3 
#44 0xb701c9b7 in QApplication::notify () from /usr/lib/libqt-mt.so.3 
#45 0xb7743db2 in KApplication::notify () from /usr/lib/libkdecore.so.4 
#46 0xb6fad389 in QApplication::sendEvent () from /usr/lib/libqt-mt.so.3 
#47 0xb700cf81 in QEventLoop::activateSocketNotifiers () 
    from /usr/lib/libqt-mt.so.3 
#48 0xb6fc1ea7 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3 
#49 0xb703525e in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3 
#50 0xb703506e in QEventLoop::exec () from /usr/lib/libqt-mt.so.3 
#51 0xb701c731 in QApplication::exec () from /usr/lib/libqt-mt.so.3 
#52 0x0805ad81 in ?? () 
#53 0xbfdfe760 in ?? () 
#54 0x00000001 in ?? () 
#55 0x00000001 in ?? () 
#56 0x00000000 in ?? () 

After this step my cached Inbox was completely erased except one single mail (the first one in the folder). - I then checked my webmail access to this account. But there all mails were still in the folder. 
 
3. I then tried to start KMail a third time and also tried to again refresh the local IMAP cache. But it again crashed with this: 
 
[KCrash handler] 
#6  0x08398834 in ?? () 
#7  0xb58460b8 in ?? () from /usr/lib/libkmailprivate.so 
#8  0xb553d94e in KMHeaders::msgRemoved () from /usr/lib/libkmailprivate.so 
#9  0xb5548f39 in KMHeaders::qt_invoke () from /usr/lib/libkmailprivate.so 
#10 0xb7036957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#11 0xb5577fd0 in KMFolder::msgRemoved () from /usr/lib/libkmailprivate.so 
#12 0xb5578c8d in KMFolder::qt_emit () from /usr/lib/libkmailprivate.so 
#13 0xb703692b in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#14 0xb5595bd0 in FolderStorage::msgRemoved () 
    from /usr/lib/libkmailprivate.so 
#15 0xb559706c in FolderStorage::take () from /usr/lib/libkmailprivate.so 
#16 0xb563eb2c in KMFolderMaildir::take () from /usr/lib/libkmailprivate.so 
#17 0xb562e88b in KMFolderCachedImap::take () from /usr/lib/libkmailprivate.so 
#18 0xb557688e in KMFolder::take () from /usr/lib/libkmailprivate.so 
#19 0xb5642685 in KMFolderMaildir::addMsgInternal () 
    from /usr/lib/libkmailprivate.so 
#20 0xb5642fa7 in KMFolderMaildir::addMsg () from /usr/lib/libkmailprivate.so 
#21 0xb55947a3 in FolderStorage::moveMsg () from /usr/lib/libkmailprivate.so 
#22 0xb55769c5 in KMFolder::moveMsg () from /usr/lib/libkmailprivate.so 
#23 0xb55c33a6 in KMFilterMgr::process () from /usr/lib/libkmailprivate.so 
#24 0xb5535a42 in KMAccount::processNewMsg () from /usr/lib/libkmailprivate.so 
#25 0xb562fca0 in KMFolderCachedImap::addMsgInternal () 
    from /usr/lib/libkmailprivate.so 
#26 0xb56fa23d in KMail::CachedImapJob::slotGetNextMessage () 
    from /usr/lib/libkmailprivate.so 
#27 0xb56f7812 in KMail::CachedImapJob::qt_invoke () 
    from /usr/lib/libkmailprivate.so 
#28 0xb7036957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#29 0xb6b1777e in KIO::Job::result () from /usr/lib/libkio.so.4 
#30 0xb6b57a8d in KIO::Job::emitResult () from /usr/lib/libkio.so.4 
#31 0xb6b6b75e in KIO::SimpleJob::slotFinished () from /usr/lib/libkio.so.4 
#32 0xb6b6be6d in KIO::TransferJob::slotFinished () from /usr/lib/libkio.so.4 
#33 0xb6b576ba in KIO::TransferJob::qt_invoke () from /usr/lib/libkio.so.4 
#34 0xb7036957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#35 0xb70373fc in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#36 0xb6b11ffc in KIO::SlaveInterface::finished () from /usr/lib/libkio.so.4 
#37 0xb6b77720 in KIO::SlaveInterface::dispatch () from /usr/lib/libkio.so.4 
#38 0xb6b7575a in KIO::SlaveInterface::dispatch () from /usr/lib/libkio.so.4 
#39 0xb6b2643c in KIO::Slave::gotInput () from /usr/lib/libkio.so.4 
#40 0xb6b65360 in KIO::Slave::qt_invoke () from /usr/lib/libkio.so.4 
#41 0xb7036957 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#42 0xb703726e in QObject::activate_signal () from /usr/lib/libqt-mt.so.3 
#43 0xb73c3cdb in QSocketNotifier::activated () from /usr/lib/libqt-mt.so.3 
#44 0xb7059516 in QSocketNotifier::event () from /usr/lib/libqt-mt.so.3 
#45 0xb6fcdb88 in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3 
#46 0xb6fcf9b7 in QApplication::notify () from /usr/lib/libqt-mt.so.3 
#47 0xb76f6db2 in KApplication::notify () from /usr/lib/libkdecore.so.4 
#48 0xb6f60389 in QApplication::sendEvent () from /usr/lib/libqt-mt.so.3 
#49 0xb6fbff81 in QEventLoop::activateSocketNotifiers () 
    from /usr/lib/libqt-mt.so.3 
#50 0xb6f74ea7 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3 
#51 0xb6fe825e in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3 
#52 0xb6fe806e in QEventLoop::exec () from /usr/lib/libqt-mt.so.3 
#53 0xb6fcf731 in QApplication::exec () from /usr/lib/libqt-mt.so.3 
#54 0x0805ad81 in ?? () 
#55 0xbf9ffb60 in ?? () 
#56 0x00000001 in ?? () 
#57 0x00000001 in ?? () 
#58 0x00000000 in ?? () 
 
Now all mails also were erased from the server and so I lost my Inbox again. 

Later on I had another mail loss with my second account and dimap. I had 13 mails in my inbox and was reading several mails in this folder (GMX Account). I then right clicked my inbox and selected "Troubleshoot IMAP cache" -> "Rebuild Index". I got a message that rebuilding index was successful. Everything still looked fine. 

After the next synchronize 10 of my 13 mails were deleted from the server and by the second synchronize they also were deleted locally. I did this several times now by copying some mails in my inbox, rebuilding index and synchronizing twice. Each time many of the mails in my inbox were deleted after synchronizing twice.
Comment 1 Laurent Pelecq 2007-02-10 14:07:17 UTC
I experienced the same problem (same stack trace). Each time kmail crashes. I didn't had any message lost. Maybe because I ran cache update as soon as I started kmail without trying to synchronize first.
Comment 2 Marcel Schaal 2007-11-06 18:07:10 UTC
Using Ubuntu Gutsy we also experienced the problem of losing emails when kmail crashes. I don't know if it is a ubuntu specific bug because we don't have other distributions available at the moment. Gutsy uses Kmail 1.9.6 (enterprise 0.20070907.709405). Just bacula rescued a whole bunch of emails.

Comment 3 Marcel Schaal 2007-12-04 18:24:53 UTC
I lost my mails in inbox again while I removed some subscriptions. My IMAP-Server changed from courier to dovecot, so it doesn't seem to be a serverproblem. Thx to dovecot and lazyexpunge my mails are safe from being deleted from kmail. I must admit that there should be at least a warning using dimap that u could lose your emails!

Yesterday this bug occured twice when I first ran kmail on the computer of my girlfriend. The emails in her inbox also got removed after changing subscription.

Common guys it isn't funny for a user to lose mails. Now it's possible for me to restore the mails, but think about other users which don't have any experience and access to the server. Kmail doesn't simply delete the mails it expunges them.

This is a severe bug in my opinion and it lasts long enough. I will try to reproduce it again.
Comment 4 Yözen Hernández 2008-06-11 02:40:11 UTC
*** This bug has been confirmed by popular vote. ***
Comment 5 Yözen Hernández 2008-06-11 02:50:38 UTC
This bug is most definitely confirmed on my machine. Last year, it affected my desktop and erased my whole inbox from my old gmail account which made me never use kmail on my desktop again. Since my laptop never gave me trouble, I continued to use it there.

Today, however, it nearly happened again.I say nearly because all of my messges disappeared from my inbox in kmail, but fortunately not in gmail. This happened after trying to sync and then getting an error about not being able to get permissions for the inbox folder. I reflexively pressed "Continue", the default option, and say all the inbox folder cleared. When I attempted to sync once again, to restore my messages, I notice that the progress bar indicated it was deleting all "removed" messages from the folder on the server. I stopped it in time and only lost my 5 oldest messages.

The first time, on my desktop, I did not see the dialog box about the permission error. That was on Kubuntu 7.10. Today's incident occurred on a laptop running Kubuntu 8.04
Comment 6 Chris 2008-08-11 22:58:53 UTC
Now this problem again appeared with kmail 3.5.9 in Scalix mode (so also running with dimap). While kmail was running, another (!) file system mounted via NFS became unavailable so some programs did not respond any more. So I restarted the machine and started kmail again. Now I lost all my mail again - just the empty folder structure was left after the mail sync was finished.
Comment 7 Jani-Matti Hätinen 2008-08-15 15:44:47 UTC
I can confirm that this bug is still present in kmail-1.10.0 on kde-4.1.0 on ubuntu-8.04.

If a dimap sync is interrupted for whatever reason, on the next sync kmail will usually try to remove those messages, which it could not retrieve earlier.
 
Furthermore, syncing a gmail account with more than a few hundred messages seems to be completely impossible at least on  a slower connection. Although that could also be a timeout issue in the gmail server end.

Please, please fix dimap so that won't eat people's e-mail under any circumstances. The current situation is simply unacceptable, especially considering how long bugs like this have been open.
Comment 8 Jani-Matti Hätinen 2008-08-15 16:09:04 UTC
The easiest way to fix this is to reimplement dimap with journaling. Along with the local message cache there's also a local transaction cache. As with the message cache, each item in the transaction cahce is stored in a separate file (to minimise the possible effects of corruption).

Whenever the user does something to a message locally (mark read, mark unread, mark important, move, copy, etc.), the action is stored in the transaction cache as well as the message state in the local message cache.

When syncing to the server the items in the local transaction cache are reviewed one by one. If syncing to server is successful, the item in the transaction cache is marked as done. If syncing to server fails because the server state differs from the local state (message has already been removed, marked read, marked important, etc.), the item is marked as failed and ignored in further syncs. If syncing fails for any other reason (timeout, server down, etc.), the item is left in the transaction cache as open.

Only when/if the local transaction cache is empty, the state between local message cache and server message store is compared and all differences are synced _from_ the server _to_ the client.

For error situations the GUI can provide options for cleaning and/or reviewing the local transaction cache (in case particular transactions cause consistent errors).

I'm not sure how close the current implementation is from the one I described, but from what I understand the above design shouldn't require too much refactoring.
Comment 9 Donatas Glodenis 2008-08-22 18:49:40 UTC
I can confirm I have experienced this problem a number of times with different kmail versions in dimap accounts. 

Today, after transferring a lot of mail to gmail archive via dimap and a few crashes I lost ability to check mail in gmail accountf see bug  #169599
Comment 10 Yözen Hernández 2008-09-30 23:32:07 UTC
Looks like this bug is a duplicate of yet another bug, one that is FIVE YEARS OLD (bug #63353). Looks like we shouldn't be expecting a fix anytime soon...
Comment 11 Jani-Matti Hätinen 2008-12-12 00:58:05 UTC
For me personally both kmail-1.9.10 (which ships with KDE-3.5.10) and kmail-1.10.92 (an SVN trunk checkout from 2008.12.09) don't exhibit this problem, so I'm cool. (Others may disagree, but I'd urge them to test with the latest SVN version, or at least with kmail-1.9.10 or KDE-4.2 once it's released, so we can close bugs like this)

BTW, for the record, I use gmail with roughly 1,7GB of mail since early 2005 in two different accounts, one of them comprising 19 extra folders (in addition to the 8 default gmail folders)
Comment 12 Björn Ruberg 2010-01-03 00:34:56 UTC
Please report whether this is still an issue in recent kmail
Comment 13 mgolden 2010-01-03 02:47:34 UTC
Is there some reason to suppose that the problem has disappeared?  Has there been a fix or rewrite to dimap?
Comment 14 Björn Ruberg 2010-01-03 10:27:18 UTC
Yes, in the KDE 4.2 line there has been some bugfixing on IMAP code. Moreover I'm using kmail extensively since then and never found this problem. All reports here are older than KDE 4.2.
Comment 15 Richard Clayton 2010-07-21 21:26:53 UTC
Are these possibly the same bugs?

https://bugs.kde.org/show_bug.cgi?id=164679