Bug 286047

Summary: dimap account requires network connection
Product: [Frameworks and Libraries] Akonadi Reporter: Milian Wolff <mail>
Component: IMAP resourceAssignee: kdepim bugs <kdepim-bugs>
Severity: normal CC: amantia, dschridde+kde, kdepim-bugs, vkrause
Priority: NOR    
Version: 1.0.0   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In: 4.11

Description Milian Wolff 2011-11-07 21:32:28 UTC
Version:           Git (master)
OS:                Linux

first up: not sure if this belongs here, it's probably an issue with the dimap agent that is in kdepim-runtime, or?

now to the actual bug report:
when I have no inet connection, i.e. during startup or esp. on resume from suspend, my dimap accounts go into offline mode.

When this happens, I cannot access my mail anymore. See also bug 286045. Akonadiconsole shows my agents in offline mode with "could not connect to mymail.somehost.com" error message. I have to toggle them online manually and restart kmail to get access to my mail.

now I wonder why this happens, dimap == disconnected == I want at least access to my disconnected cache even if I have no net connection

Reproducible: Didn't try

Steps to Reproduce:
- start kmail 2 with dimap account
- suspend to ram
- resume
- check mail and try to access your inbox

Actual Results:  
multiple things can happen:

- endlessly spinning bug 286045
- no mails show up
- only "new" mails, but no cached/old mails

Expected Results:  
- always show cached items
Comment 1 Milian Wolff 2011-11-23 22:35:24 UTC
note that this was much easier to reproduce until recently, no it got better but I still encounter this error from time to time. Now with bug 286045 fixed I see this error message in such cases:

Unknown error. (Unable to fetch item from backend)

this was also confirmed by antlarr in #kontact irc today, but not real solution was found, nor an easy way to trigger it. here is the irc log for the record:

[20:27] <antlarr> [16:21:43] andris, milian : about the problem with "retrieving folder contents. Please wait"... I got it again
[20:27] <antlarr> [16:21:59]  akonadiconsole shows the agent is online, idle
[20:27] <milian> [16:22:03] antlarr: please open akonadiconsole, what do you see there - errors ?
[20:27] <milian> [16:22:04] ah hm
[20:27] <andris> [16:22:14] hm
[20:27] <krop> [16:22:23] allen_kdab: you can define a local gitignore file if you want (for repos without .gitignore)
[20:27] <antlarr> [16:22:24] I just enabled the debugger now
[20:27] <antlarr> [16:22:45] should I enable "job tracker", etc ?
[20:27] <antlarr> [16:23:09] do you want me to put the agent offline/online ?
[20:27] <antlarr> [16:23:14] gdb any process ?
[20:27] <andris> [16:23:52] manny things could be tried
[20:27] <allen_kdab> [16:23:56] krop: yes but I figured since the repo's .gitignore already had .kdev stuff, then 
[20:27] <antlarr> [16:24:00] andris: :)
[20:27] <antlarr> [16:24:07] andris: tell me :)
[20:27] <andris> [16:24:09] enable the debugger (not the job tracker) is one
[20:27] <andris> [16:24:22] gdb-ing the akonadi_imap_resource or the akonadiserver is another
[20:27] <antlarr> [16:24:29] kontact-2096466285 (0x85ee9a0) 595 NO Unable to fetch item from backend 
[20:27] <antlarr> [16:24:44] I'm getting those in akonadi's debugger
[20:27] <allen_kdab> [16:24:53] krop: do you want me to remove that entry from the repo's .gitignore?
[20:27] <andris> [16:25:03] it tells the error, just not the reason
[20:27] <krop> [16:25:04] no no, that's fine 
[20:27] <andris> [16:25:57] antlarr: sec, i need to load kdepim into kdevelop
[20:27] <antlarr> [16:26:13] each 20 seconds or so I get a couple more lines (if you want better timings, tell me)
[20:27] <andris> [16:26:37] are those also fetch comand with the same error response?
[20:27] <antlarr> [16:26:44] btw
[20:27] <antlarr> [16:26:49] each ID fetched is tried twice
[20:27] <antlarr> [16:27:10] andris: yes
[20:27] <antlarr> [16:27:17] always the same error response
[20:27] <antlarr> [16:27:26] (with different sequence ID, of course :) )
[20:27] <andris> [16:27:26] try to gdb into akonadi_imap_resource
[20:27] <andris> [16:27:30] and see what it does
[20:27] <antlarr> [16:28:06] it has two threads
[20:27] <antlarr> [16:28:32] one of them is in QEventDispatcherGlib::processEvents
[20:27] <antlarr> [16:28:50] and the other too
[20:27] <antlarr> [16:29:02] (in fact, in a poll system call)
[20:27] <andris> [16:29:24] do you have a debug build for kdepim-runtime?
[20:27] <antlarr> [16:30:25] nop, I'm at work here :(
[20:27] <antlarr> [16:30:39] I'm installing now the -dbg package and I'll see if I can use it
[20:27] <antlarr> [16:30:52] (I'm using kubuntu here)
[20:27] <andris> [16:30:58] i'm not sure it helps if you already have the app running
[20:27] <CIA-5> [16:31:02] Christophe Giboudeaux master * v4.7.0-1767-g3089dff [kdepim] / (CMakeLists.txt cmake/modules/FindGit.cmake) 
[20:27] <CIA-5> [16:31:02] Get rid of the FindGit.cmake copy. 
[20:27] <CIA-5> [16:31:02] http://commits.kde.org/kdepim/3089dff99d23e3a638c58d17bf08714b14e2e030
[20:27] <andris> [16:31:07] the idea would be to debug into the resource why it fails
[20:27] <andris> [16:31:15] I could give some hints where to put breakpoints
[20:27] <andris> [16:32:52] also (in  the future) try to enable the debug area for akonadi_imap_resource and start akonadiserver from a console (akonadictl start) maybe we can learn something extra from the debug outputs
[20:27] <andris> [16:33:12] be sure to disable the debugger in akonadiconsole when you don't need, it will make things much slower
[20:27] <antlarr> [16:34:20] Reading symbols from /usr/bin/akonadi_imap_resource...Reading symbols from /usr/lib/debug/usr/bin/akonadi_imap_resource...done.
[20:27] <antlarr> [16:34:30] yep, it works with a running app :)
[20:27] <andris> [16:35:14] try a breakpoint in ImapResource::retrieveItem and see if it is hit
[20:27] <antlarr> [16:37:36] btw, this is a kolab server and I saw there's a akonadi_kolabproxy_resource app running too, I guess akonadi_imap_resource is the right one anyway, right?
[20:27] <antlarr> [16:37:59] it's not stopping at that method
[20:27] <antlarr> [16:38:12] I saw some more fetches in the debugger
[20:27] <andris> [16:38:19] yes, the imap resource is the right one
[20:27] <antlarr> [16:38:24] since I put the breakpoint
[20:27] <andris> [16:38:40] hm, ervin would be your real man for imap debugging...
[20:27] <andris> [16:39:03] he is online on #akonadi, maybe you can ask some hints where to put the breakpoint
[20:27] <andris> [16:39:33] i was expecting that you hit that method
[20:27] <antlarr> [16:42:14] well, the name seems promising...
[20:27] <CIA-5> [16:43:05] Montel Laurent master * v4.7.0-1768-g1b41d21 [kdepim] / (kmail/kmreadermainwin.cpp messageviewer/viewer_p.cpp) 
[20:27] <CIA-5> [16:43:05] Now we can copy embedded item in an other folder. 
[20:27] <CIA-5> [16:43:05] http://commits.kde.org/kdepim/1b41d21f483db27b6b57f23960ba053868c14b26
[20:27] <antlarr> [16:44:14] gdb told me that method was at ../../../resources/imap/imapresource.cpp, line 262 so I put a breakpoint on 260, 261, 262, 263 ... up to 269 :)
[20:27] <antlarr> [16:44:19] and nothing
[20:27] <andris> [16:44:32] another hint
[20:27] <andris> [16:44:48] now gdb akonadiserver
[20:27] <andris> [16:45:43] and break at bool ItemRetriever::exec()
[20:27] <antlarr> [16:45:57] wow, 26 threads :)
[20:27] <andris> [16:46:11] yeah, akonadi *is* multitheaded :)
[20:27] <andris> [16:46:20] guess why sqlite doesn't like it
[20:27] <antlarr> [16:47:37] Function "ItemRetriever::exec" not defined
[20:27] <antlarr> [16:48:08] I'm installing more -dbg packages
[20:27] <antlarr> [16:49:55] nope, I installed also akonadi-dbg and it still tells me ItemRetriever::exec is not defined
[20:27] <antlarr> [16:50:10] in which library should that be defined?
[20:27] <andris> [16:51:29] it is inside akonadiserver, not a lib
[20:27] <kde-ci-bot> [16:54:05] Project kdepim_master build #790: STILL UNSTABLE in 9 min 42 sec: http://build.kde.org/job/kdepim_master/790/
[20:27] <kde-ci-bot> [16:54:05] * cgiboudeaux: Get rid of the FindGit.cmake copy.
[20:27] <kde-ci-bot> [16:54:06] * montel: Now we can copy embedded item in an other folder.
[20:27] <antlarr> [16:54:08] ops
[20:27] <antlarr> [16:54:20] andris: I guess kubuntu packages are stripped
[20:27] <andris> [16:54:50] aren't there an akonadiserver-dbg?
[20:27] <antlarr> [16:56:58] aah
[20:27] <antlarr> [16:57:03] maybe it's inside a namespace ?
[20:27] <andris> [16:57:17] namespace Akonadi indeed
[20:27] <antlarr> [16:59:45] now :)
Comment 2 Milian Wolff 2011-11-25 11:41:07 UTC
ok, finally got it again myself.

started kmail, wicd failed to get inet connection. kmail showed error messages that it could not get email (why didn't it detect that there is no active inet connection?).

then wicd managed to get inet, kmail showed me the "go online" dialog, I selected it. but I still have the issue above. looking at akonadiconsole, I see my dimap accounts with the following error message:

"Could not connect to the IMAP-Server ... Failed to connect to server."

It seems as if the agent does not recover from that issue. Furthermore of course even in such a case, I should be able to see the mails form my disconnected cache, but that only works in some folders. When selecting a folder I get this error message _twice_:

Unknown error. (Unable to fetch item from backend)

I think it can be reproduced by trying to connect to some wlan network with wicd but passing wrong credentials?
Comment 3 Milian Wolff 2011-11-25 11:41:49 UTC
oh and of course: toggling the agents to "online" manually in akonadiconsole makes it all work again.
Comment 4 David Faure 2012-01-06 12:25:20 UTC
Git commit 679a05cb8ee30c81ea207b6cfc0e4131fd1a0c78 by David Faure.
Committed on 06/01/2012 at 13:21.
Pushed by dfaure into branch 'master'.

Restore the default timeout to 30s, after the kdelibs+kdepimlibs fixes.

The timeout doesn't trigger by mistake anymore on large emails,
so it can be restored to 30s, in order to fix the issues with
network disconnections, suspend/resume etc.
Related: bug 258378, bug 258271, bug 257722

M  +1    -1    resources/imap/imapresource.kcfg

Comment 5 András Manţia 2013-03-03 14:06:32 UTC
Git commit c004365e4ce815d341aa2098ad412f450dc65336 by Andras Mantia.
Committed on 03/03/2013 at 11:32.
Pushed by amantia into branch 'master'.

Fetch the missing mail bodies in offline mode (requires fixed in Akonadi server and Akonadi client libraries as well to work).
Related: bug 264629, bug 255578

FIXED-IN: 4.11

M  +6    -1    resources/imap/imapresource.cpp
M  +1    -0    resources/imap/imapresource.h
M  +76   -7    resources/imap/retrieveitemstask.cpp
M  +11   -3    resources/imap/retrieveitemstask.h

Comment 6 Dennis Schridde 2013-03-03 15:40:08 UTC
Can we please get a backport to 4.10?
Comment 7 András Manţia 2013-03-03 15:50:37 UTC
I cannot promise. The linked commit is only part of the fix. It needs not-yet-released Akonadi server, changes in the Akonadi client library (new API), that is not allowed to be introduced in patch releases.