Bug 297930

Summary: Kmail hangs on "Retrieving folder contents ... please wait" when loading a message with an attached .ics file
Product: [Applications] kmail2 Reporter: searchfgold67899
Component: miscAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: aaronw, andrej.programiranje, bingmybong, bugs, g.sora, h.k.ghost, ianseeks, joshua, kde, kde, kdebugs, kotsifi, leviatan1, marat, marc_bessieres, mfraz74+kde, montel, null, paul, roberto.castagnola, searchfgold67899, simone, tprotopopescu
Priority: NOR Keywords: regression
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
URL: http://wstaw.org/m/2012/04/11/plasma-desktopoe1748.jpg
Latest Commit: Version Fixed In: 14.12
Sentry Crash Report:

Description searchfgold67899 2012-04-11 21:09:36 UTC
User-Agent:       Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) rekonq Safari/534.34
Build Identifier: 

When I try to open an email message, I see the message "Retrieving folder contents

Please wait.  .  ."
With a blue background and the Kmail logo. (snapshot: http://wstaw.org/m/2012/04/11/plasma-desktopoe1748.jpg) It hangs there. I can close KMail still, and when I do, the bug reporter shows up, taking me here. I can also select other emails but that does not get rid of the screen.

Reproducible: Always

Steps to Reproduce:
1. Open Kmail.
2. Try to open an email.
3. Sometimes emails will open, but after clicking two or three emails it always freezes.
Actual Results:  
Blue screen with "Recieving folder Contents".

Expected Results:  
Expected the email contents to appear.

richie@richie-Dimension-4600i:~$ kmail
richie@richie-Dimension-4600i:~$ kmail2(5443) MessageViewer::Util::fileNameForMimetype: unknown mimetype "" 
kmail2(5443) MessageViewer::Util::fileNameForMimetype: unknown mimetype "" 
kmail2(5443) MessageViewer::Util::fileNameForMimetype: unknown mimetype "application/ics" 
kmail2(5443) MessageViewer::Util::fileNameForMimetype: unknown mimetype "application/ics"
Comment 1 Laurent Montel 2012-04-12 06:36:27 UTC
kmail version ?
Do you have an invitation in this email ?
do you have an calendar configurated ?
Comment 2 searchfgold67899 2012-04-12 14:35:29 UTC
Kmail version: 4.7.3
Oddly enough, this only happens after I click a message with an invitation in it, that is, and .ics file. 
I do not have a calendar configured, but I'm opening Kmail via kontact.
Comment 3 Laurent Montel 2012-04-12 15:29:03 UTC
Already fixed in 4.8
Comment 4 Igor Zhuravlov 2012-11-19 04:00:40 UTC
When I try to open an email message, I see the message "Retrieving folder contents Please wait..." approx. 30 seconds, after that message's content appears OK.

Some messages (~10%) appears immediately.

KMail version: 4.8.5
KDE version: 4.8.5 (4.8.5) "release 2"
OS: openSUSE 12.2 (i586)
Linux kernel: 3.4.11-2.16-desktop
Comment 5 searchfgold67899 2013-11-20 00:23:01 UTC
Reproducible in 4.11.2
Comment 6 g.sora 2013-12-05 13:31:47 UTC
I confirm same problem on OpenSuSE 13.1 (Kde 4.11.2) after upgrading from OpenSuSE 12.3 (Kde 4.10.5). 
The same on another PC with Kubuntu 12.10 upgraded with KDE 4.11.3.
I have to manage a lot of accounts some IMAP some POP3.
This is a serious bug preventing using in a decent way KMail. I even tried to reset akonadi with everything linked to it under kubuntu, but the only results was I missed my messages of e-mail. 
In the past, from time to time, I had to stop akonadi services to see kmail just working, or deactivating html, but now this is not enough. Maybe some problems with MariaDB too?
Comment 7 g.sora 2013-12-10 13:14:38 UTC
(In reply to comment #6)
> I confirm same problem on OpenSuSE 13.1 (Kde 4.11.2) after upgrading from
> OpenSuSE 12.3 (Kde 4.10.5). 
> The same on another PC with Kubuntu 12.10 upgraded with KDE 4.11.3.
> I have to manage a lot of accounts some IMAP some POP3.
> This is a serious bug preventing using in a decent way KMail. I even tried
> to reset akonadi with everything linked to it under kubuntu, but the only
> results was I missed my messages of e-mail. 
> In the past, from time to time, I had to stop akonadi services to see kmail
> just working, or deactivating html, but now this is not enough. Maybe some
> problems with MariaDB too?
Removing some files under local/share/akonadi, after akonadtctl stop, then executing akonadictl start, partially solve the problem, in a very very long time. Pls remember to restart your whole system.  What you get is a system with the all filters mixed and  the account boxes mixed too. This is really annoying if you have many accounts and many computers to manage. Now all seems ok, but after 2 days of e-mail stop. Really this is non acceptable for production systems.
Comment 8 francisco_t 2013-12-22 15:24:04 UTC
Same problem with update from 4.11.2 to 4.11.3 in kubuntu 13.10.
Comment 9 Marc Bessières 2013-12-23 16:38:57 UTC
Hi,

Yesterday, I upgraded from opensuse 12.3 to 13.1, and kmail(4.11.3) was blocked opening messages, using a lot of cpu for kmail, akonadi and mysql.
Looking for a solution I found this bug report that looked like my issue.

But the solution to fix my issue was in https://bugs.kde.org/show_bug.cgi?id=322958

I summarize, but you can read the other bug report.

run akonadiconsole
in the akonadiconsole tab Browser look for duplicate entries, for me all were duplicated (Inbox, Outbox, Templates...) and remove the duplicate ones, but only the ones that are empty.

Then I launched again kmail and it was fine.

Can you check if this workaround fixes your issue?
This would mean this bug entry is a duplicate.

Cheers
Comment 10 g.sora 2013-12-23 17:11:48 UTC
Hi,
I do not remember all the steps I did before getting a running solution, but 
for sure, at least  on one machine, the cleaning of duplicate was not enough 
(by the way I made a duplicate cleaning on both the systems). So I had to 
manually clean (i.e. delete) some files under the akonadi directory and so, 
after a long while I got a working system.

On next days I will try to upgarde another machine, so if I will face the same 
problem I will be going to apply your solution  in a neat way and I will be 
able to tell you if it is working or not on it.

cheers
Giovanni

Le Lunedi 23 Decembre 2013 16:38:57 tu scribeva:
> https://bugs.kde.org/show_bug.cgi?id=297930
> 
> Marc Bessières <marc_bessieres@yahoo.fr> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
> CC|                            |marc_bessieres@yahoo.fr
> 
> --- Comment #9 from Marc Bessières <marc_bessieres@yahoo.fr> ---
> Hi,
> 
> Yesterday, I upgraded from opensuse 12.3 to 13.1, and kmail(4.11.3) was
> blocked opening messages, using a lot of cpu for kmail, akonadi and mysql.
> Looking for a solution I found this bug report that looked like my issue.
> 
> But the solution to fix my issue was in
> https://bugs.kde.org/show_bug.cgi?id=322958
> 
> I summarize, but you can read the other bug report.
> 
> run akonadiconsole
> in the akonadiconsole tab Browser look for duplicate entries, for me all
> were duplicated (Inbox, Outbox, Templates...) and remove the duplicate
> ones, but only the ones that are empty.
> 
> Then I launched again kmail and it was fine.
> 
> Can you check if this workaround fixes your issue?
> This would mean this bug entry is a duplicate.
> 
> Cheers
Comment 11 tony den haan 2014-01-24 09:55:38 UTC
I've been running into this problem frequently for probably years already. akonadictl restart 'fixes' it.
but it's pretty absurd kmail will stay in this state forever.
Comment 12 Paul Campbell 2014-07-06 08:20:20 UTC
I ran into this problem when taking the new KDE upgrade in kubuntu- trusty this week

All emails from meetup.com (containing .ics files) cause kmail to freeze, restarting akonadi unfreezes, but touching the email makes it freeze again.

The fix I found was to go into the akonadi setup (Control Panel->Personal Information) and create an ics calendar entry (I actually made several types of calender entry so it might have been something else) - this means I can now read the emails, and even better delete them
Comment 13 Evgeny Brazgin 2014-08-26 17:54:59 UTC
I have the same problem. And when kmail tries to open a message, in Akonadi Console I see repeating lines like the following:

59985 MERGE (REMOTEID SILENT) 30 0 (\MimeType[message/rfc822] "\\RemoteId[58496]" \SEEN) () 
59985 [UIDNEXT 150741 DATETIME "26-Aug-2014 17:45:44 +0000"] 
59985 OK Merge completed 

Sometimes waiting for a long time helps (the numbers in the begining of the lines go up to 60000 and finally the message appears).
Comment 14 Simone Lazzaris 2014-09-19 07:38:13 UTC
Same problem heere.
Kmail 4.14.0 on archlinux x86_64.

I've looked at the akonadi db with the akonadi console and I DON'T have the duplicated folder.

A few days ago I've "solved" the very same problem deleting all the akonadi folders and reconfiguring the account, but now I'm stuck with this problem again.

Restarting akonadi doesn't have any result... I'm still stuck on "Retreiving folder content".


On the  akonadi console, I see a run with is running and doesn't progress: its type is "IncidenceFetchJob" and it seems it's waiting for a child (type CollectionFetchJob) which IS finished (state: ended).


If more info is needed, I'm willing to help.
Comment 15 h.k.ghost 2014-10-28 04:38:19 UTC
I see this behavior, usually when I set it to "Work offline" and, after a while (e.g. stopped using VPN), try to set it back to "Work online". At this point it gets stuck forever trying to retrieve remote folders.

Restarting Kontact/KMail does not fix it, even though I see the "Connection established" reach 100% and go away normally. Trying to abort the operation hangs as well. Note, however, that I can still send emails without problems. It's retrieving them that stops working.

I normally have to log out and then back in, in order for it to get itself 'fixed'. It seems easy to reproduce, at least in my machine.

Kontact/KMail: 4.14.1
Distro: Kubuntu 14.10 AMD64
Kernel: Linux 3.16.0-23-generic
Comment 16 Daniel Vrátil 2014-11-10 13:08:39 UTC
Git commit b73e783f35510d6ed1620e4c3af1f110cfc8b741 by Dan Vrátil.
Committed on 10/11/2014 at 13:07.
Pushed by dvratil into branch 'KDE/4.14'.

IncidenceFetchJob: don't get stuck when no calendar collections exist

The job never emitted finished() when the CollectionFetchJob returned no
collections. This causes KMail to get stuck when user opens an invitation
without having any calendar resource set up.
FIXED-IN: 4.14.4

M  +6    -0    akonadi/calendar/incidencefetchjob_p.cpp

http://commits.kde.org/kdepimlibs/b73e783f35510d6ed1620e4c3af1f110cfc8b741
Comment 17 tony den haan 2016-09-29 07:35:56 UTC
It just happened again here, akonadictl restart fixed it

Version 5.1.3

KDE Frameworks 5.18.0

Qt 5.5.1 (built against 5.5.1)
Comment 18 Dimitris Diamantis (aka ftso) 2016-10-05 15:01:36 UTC
Same problem here...

Version 5.2.3
KDE Frameworks 5.25.0
Qt 5.6.1 (built against 5.6.1)
The xcb windowing system

'akonadictl restart' fixes the problem until the next hang.
Comment 19 Joshua J. Kugler 2016-10-06 20:29:58 UTC
Just hit this problem today.

KMail Version: 5.1.3
KDE Plasma Version: 5.6.5
KDE Frameworks Version: 5.23.0
Qt Version: 5.5.1

Thanks Dimitris for the work-around!
Comment 20 BingMyBong 2016-12-22 18:35:47 UTC
kmail 5.4
 This is happening fairly often and when you close kmail it sometimes crashes akonadiserver and/or you get lots of these messages 
org.kde.pim.akonadicore: Got a stale notification for an item which was already removed. 40802 ""
org.kde.pim.akonadicore: Got a stale notification for an item which was already removed. 40802 ""
You can use akonadiconsole and stop / start the server and it sometimes allows kmail to work again.
Comment 21 tprotopopescu 2017-01-04 10:22:12 UTC
I have the same problem. It seems to me that maybe this bug should be re-opened, and the severity increased from normal to severe; this happens basically whenever I change folders, sometimes when I just change emails within the same folder.

`akonadictl restart' temporarily fixes the problem most of the time, sometimes I have to do it twice just to see an email. 


Kmail 5.4.0
Framework 5.29.0
Plasma 5.8.4
Qt 5.7.1
Comment 22 BingMyBong 2017-01-04 16:31:51 UTC
(In reply to tprotopopescu from comment #21)
> I have the same problem. It seems to me that maybe this bug should be
> re-opened, and the severity increased from normal to severe; this happens
> basically whenever I change folders, sometimes when I just change emails
> within the same folder.
> 
> `akonadictl restart' temporarily fixes the problem most of the time,
> sometimes I have to do it twice just to see an email. 
> 
> 
> Kmail 5.4.0
> Framework 5.29.0
> Plasma 5.8.4
> Qt 5.7.1

it is being worked on. i posted the problem on the KDE-PIM mailing list and Daniel, the developer, said he was aware of the problem and will be working on it over the christmas period
Comment 23 tprotopopescu 2017-02-03 08:16:40 UTC
For what it is worth, this problem seemed solved for a little while, but in the past week I have seen a major increase in the frequency of this behaviour. I can see messages in the inbox, but trying to view messages in any other folder basically freezes akonadi. Sometimes if I wait long enough, ten minutes or so, the message I am trying to see will be accessed. Sometimes no at all. 

Restarting akonadi does not always fix the problem. Moreover, now sometimes while akonadi is hung I also cannot access network calendars and tasks.

Combined with this problem https://bugs.kde.org/show_bug.cgi?id=375149 KDE pim applications now no longer perform their intended function.

Akonadi used to work just fine, is it possible to roll back to a known good state while this mess is fixed?

I'm using the latest version on openSUSE Tumbleweed, updated yesterday.
Comment 24 Simone Lazzaris 2017-02-03 08:32:40 UTC
Absolutely NOT resolved and NOT fixed.
Still experiencings random freezes. Restarting akonadi sometime is not sufficient.

Archlinux, KMail 5.4.1, KDE Frameworks 5.30.0, akonadi 16.12.1.
Comment 25 ianseeks 2017-02-03 09:57:30 UTC
Definitely still happening and gets worse and worse over time. i've just set up a new user with a fresh and empty mail database and it still happens. is this a regression because the first comment is in 2012.

opensuse:tumbleweed:20170201 
Qt: 5.7.1
KDE Frameworks: 5.30.0
KDE Plasma: 5.9.0
kwin5-5.9.0-1.1.x86_64
kmail2 5.4.1
Kernel:  4.9.6-1-default
Comment 26 ianseeks 2017-02-04 18:11:20 UTC
(In reply to Simone Lazzaris from comment #24)
> Absolutely NOT resolved and NOT fixed.
> Still experiencings random freezes. Restarting akonadi sometime is not
> sufficient.
> 
> Archlinux, KMail 5.4.1, KDE Frameworks 5.30.0, akonadi 16.12.1.

I've tried increasing the innodb_buffer_pool_size=128M in ~/.local/share/akonadi/mysql.conf. (it was set to 80M which is 48 below the default).  i've not had this error of retrieving folders for a while now. I don;t know if its the real fix or just a work around.  Stop akonadiserver, mysqld first, make your change and start akonadi again.
Comment 27 Simone Lazzaris 2017-02-08 08:17:04 UTC
I've set innodb_buffer_pool_size=128M; let's see if this solves the problem.
Comment 28 ianseeks 2017-02-08 16:16:59 UTC
(In reply to Simone Lazzaris from comment #27)
> I've set innodb_buffer_pool_size=128M; let's see if this solves the problem.

I still get it now and then when it goes to open an unread email, it seems to work fine all the time with emails that are already read.
Comment 29 Roberto Castagnola 2017-02-08 17:39:32 UTC
Same issue in Gentoo Linux, but setting innodb_buffer_pool_size=128M doesn't solve it for me.
Comment 30 tprotopopescu 2017-02-09 08:00:33 UTC
Setting innodb_buffer_pool_size=128M seems to have made things better for me, but not completely solved the problem.

Inbox works reliably now, but in some folders I occasionally get duplicates of an email, that is two copies are displayed, I am not being sent duplicates. When trying to access one of these duplicates akonadi hangs. Sometimes a 'failed to retried item from backend' error will pop up, or be displayed at the bottom of the window, but not always.

If I switch back to the inbox and a message there it takes ten minutes or so before the message is displayed.
Comment 31 Andrej M. 2017-03-01 20:43:28 UTC
I didn't have this problem with KMail from applications 4.14.1 but now in applications 16.04.3 I'm experiencing it and it's extremely annoying. KMail doesn't completely freeze, but it takes a minute or two to load folder contents.

I'm using Debian Stretch.
Comment 32 Simone Lazzaris 2017-03-06 11:35:46 UTC
I've tried to inspect strace output when kmail is stuck on "retrieving folder....."

I've see many lines like:

poll([{fd=3, events=POLLIN}, {fd=5, events=POLLIN}, {fd=7, events=POLLIN}, {fd=75, events=POLLIN}, {fd=84, events=POLLIN}], 5, 17901^Cstrace: Process 2170 detached

Out of curiosity I've tracked the FD used:
lrwx------ 1 simone simone 64  6 mar 12.31 /proc/2170/fd/5 -> anon_inode:[eventfd]
lrwx------ 1 simone simone 64  6 mar 12.31 /proc/2170/fd/7 -> socket:[48922]
lr-x------ 1 simone simone 64  6 mar 12.31 /proc/2170/fd/75 -> anon_inode:inotify
lr-x------ 1 simone simone 64  6 mar 12.31 /proc/2170/fd/84 -> anon_inode:inotify

It seems that kmail is waiting for something that never happens.... I've found that if I kill the process and restart kmail, akonadi is not impacted and the kmail resume its correct behaviour.

Maybe this can help?
Comment 33 ianseeks 2017-03-06 12:13:55 UTC
(In reply to Simone Lazzaris from comment #32)
> I've tried to inspect strace output when kmail is stuck on "retrieving
> folder....."
> 
> I've see many lines like:
> 
> poll([{fd=3, events=POLLIN}, {fd=5, events=POLLIN}, {fd=7, events=POLLIN},
> {fd=75, events=POLLIN}, {fd=84, events=POLLIN}], 5, 17901^Cstrace: Process
> 2170 detached
> 
> Out of curiosity I've tracked the FD used:
> lrwx------ 1 simone simone 64  6 mar 12.31 /proc/2170/fd/5 ->
> anon_inode:[eventfd]
> lrwx------ 1 simone simone 64  6 mar 12.31 /proc/2170/fd/7 -> socket:[48922]
> lr-x------ 1 simone simone 64  6 mar 12.31 /proc/2170/fd/75 ->
> anon_inode:inotify
> lr-x------ 1 simone simone 64  6 mar 12.31 /proc/2170/fd/84 ->
> anon_inode:inotify
> 
> It seems that kmail is waiting for something that never happens.... I've
> found that if I kill the process and restart kmail, akonadi is not impacted
> and the kmail resume its correct behaviour.
> 
> Maybe this can help?

i've found its mainly a problem if you click on an unopened email.  i find if you mark all the emails as "read" before going into the folder, i very rarely get the "retrieving..." problem
Comment 34 Simone Lazzaris 2017-03-07 09:50:54 UTC
(in reply to ianseeks@btinternet.com)

That seems not true in my case: I've found that kmail freezes in (roughly) equal rates for new and old messages. 

Beside that, I've got a very high number of incoming and older mail, so marking all "not read" without actually reading them is an option I'm not willing to take.

Frankly, I'd rather change the mail client
Comment 35 Mark Fraser 2017-06-23 16:03:41 UTC
After upgrading from Kubuntu 16.10 to 17.04 I have experienced this constantly. I've even tried redoing local-mail. Seems to mainly happen when there are duplicates in that folder. Sometimes I can fix it by restarting the local mailbox.

Using KMail 5.4.3
Comment 36 Aaron Williams 2017-07-13 23:43:51 UTC
*** This bug has been confirmed by popular vote. ***
Comment 37 Aaron Williams 2017-07-13 23:45:56 UTC
I can make kmail recover by restarting akonadi. I am frequently seeing this problem and by quickly switching between emails it's easy to reproduce for me. I'm now running OpenSUSE Leap 42.2 with kmail 5.3.0. I also have akonadi configured to use Postgresql (9.6).