Bug 243775

Summary: The information about if a mail has been downloaded isn't migrated; POP3 backend fails to retrieve mail with: Error during insertion into table "PartTable" "Got a packet bigger than 'max_allowed_packet' bytes.
Product: [Frameworks and Libraries] Akonadi Reporter: Alejandro Nova <alejandronova>
Component: serverAssignee: Volker Krause <vkrause>
Status: RESOLVED FIXED    
Severity: major CC: kdepim-bugs
Priority: HI Keywords: akonadi-ports-regression
Version: unspecified   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 223438    

Description Alejandro Nova 2010-07-06 17:40:55 UTC
Version:           2.0 beta1 (using Devel) 
OS:                Linux

After loading a mail account with previous data as a Local Folder (because of a KMail 1 import), KMail 2 retrieves new mail with my POP3 account, to a point. After that point, instead of recognizing mail already there as duplicate, it simply fails with an "Unknown Error (Append failed)" message box (I only get that message box if I'm running Akonaditray)

After that, the POP3 resource says all the time "Preparing transmission from xxx" and stays at 0%, unable to retrieve mail.

Reproducible: Always

Steps to Reproduce:
1. Import a Local Folder containing data from a POP3 account.
2. Configure your POP3 account.
3. You'll get the behaviour described before.

Actual Results:  
You can't retrieve mail after Akonadi detects a duplicate entry. Akonadi fails with Unknown Error (Append failed).

Expected Results:  
Akonadi knows about duplicate entries and reindexes them, and I am able to download all of my mail.
Comment 1 Thomas McGuire 2010-07-06 22:37:15 UTC
What do you mean with "duplicate entries"?

Do you have output from the console available? Stop KMail, type akonadictl stop, wait, then akonadictl start, then start KMail and look at the console output. There might be something interesting in that console output, please paste it to pastebin.com and paste the link here. Unfortunately "Unknown Error (Append failed)" doesn't tell me that much, this bug is easier to debug with console output or a clear way to reproduce (I haven't seen that error before)
Comment 2 Thomas McGuire 2010-07-06 22:38:16 UTC
In addition to the debug output of the console, also please send the debug output of the "akonadiconsole" debugging program (the debugger tab).
Comment 3 Alejandro Nova 2010-07-06 23:15:24 UTC
Thanks for the instructions. I'll try to debug this and reach you. For now, I'm running akonadictl start 2>akonadi.err.
Comment 4 Alejandro Nova 2010-07-06 23:18:38 UTC
Got it.


[akonadiserver] Error during executing query "INSERT INTO PartTable (pimItemId, name, data, datasize, external) VALUES (:0, :1, :2, :3, :4)" :  "Got a packet bigger than 'max_allowed_packet' bytes QMYSQL3: Unable to execute statement"
[akonadiserver] Error during insertion into table "PartTable" "Got a packet bigger than 'max_allowed_packet' bytes QMYSQL3: Unable to execute statement"
[/usr/bin/akonadi_pop3_resource] akonadi_pop3_resource_2(2352)/akonadiresource (pop3) POP3Resource::cancelSync: ============== ERROR DURING POP3 SYNC ==========================
[/usr/bin/akonadi_pop3_resource] akonadi_pop3_resource_2(2352)/akonadiresource (pop3) POP3Resource::cancelSync: "No es posible guardar los correos descargados.
[/usr/bin/akonadi_pop3_resource] Error desconocido. (Append failed)"

I can append you the whole log if you want to.
Comment 5 Alejandro Nova 2010-07-06 23:32:17 UTC
About "duplicate entries", this is what happens.

1. I have my POP3 backend configured to leave messages in the server, so I can fully retrieve my mail from every machine and POP3 client out there.
2. When KMail-migrator tried to migrate my mail, it made a "Local Folders" resource with the best part of my POP3 mail and some mail from my IMAP account.
3. Local Folders has already the best part of my mail, and the POP3 backend is downloading mail to the same Local Folders (inbox, outbox, and the like). POP3 backend believes, and rightfully so, that the message hasn't been downloaded, but is there, because it's imported through Local Folders.
4. When the POP3 backend tries to download a mail that's already there (because of a different backend, Local Folders) a duplicate entry generates, but, as the downloaded mail has the same name, size and everything that the mail already there, I believe this generates a mid-air collision between 2 backends (Local Folders and POP3). That's why I spoke about "duplicate entries", to clarify myself :)
Comment 6 Thomas McGuire 2010-07-06 23:41:25 UTC
> Error during insertion into table "PartTable" "Got a packet
> bigger than 'max_allowed_packet' bytes

Ah, interesting, that explains things. I'll talk to someone who knows the Akonadi server tomorrow to see what causes this.

> POP3 backend believes, and rightfully so, that the message hasn't been 
> downloaded, but is there, because it's imported through Local Folders.

Actually, it is not "rightfully", I think we simply forgot to migrate the information which mails are already downloaded. This is a migration bug, added to my todo list.

Thanks for the information.
Comment 7 Thomas McGuire 2010-07-08 10:22:01 UTC
> > Error during insertion into table "PartTable" "Got a packet
> > bigger than 'max_allowed_packet' bytes

> Ah, interesting, that explains things. I'll talk to someone who knows the
> Akonadi server tomorrow to see what causes this.

Ok, the bug is that external filestorage for big payloads on the akonadi server are not enabled by mistake. That means even big mails are (temporarily) stored in the DB, and the DB doesn't support that. We'll fix that bug in the akonadi server soon.

> > POP3 backend believes, and rightfully so, that the message hasn't been 
> > downloaded, but is there, because it's imported through Local Folders.

> Actually, it is not "rightfully", I think we simply forgot to migrate the
> information which mails are already downloaded. This is a migration bug,
> added to my todo list.

Hmm, I actually can't reproduce this. The information of the already downloaded mails is stored in $KDEHOME/share/apps/kmail/<login>:<host>:<port>, in that file you'll see an entry "seenUidList" and "seenUidTimeList". Those two entries are the list of already downloaded mail. For me, the settings got sucessfully migrated and are now found in $KDEHOME/share/config/akonadi_pop3_resource_<number>rc.
Comment 8 Alejandro Nova 2010-07-08 20:45:02 UTC
I checked there and there's no info there, but that could be a consequence of a crash during my migration process (filed as a separate bug) that certainly could be related to the first issue (huge-mail induced indigestion).

Please, give Akonadi some Alka-Seltzer and I'll try another migration with my data when you have fixed the external filestorage mail bug ;).
Comment 9 Thomas McGuire 2010-07-22 11:35:31 UTC
Ok, the external filestorage has now been fixed in akonadi server trunk with r1151694. It will be backported to kdesupport-from-4.5 soon.
However, you need to manually enable external payloads in the akonadi server config file for this. In ~/.config/akonadi/akonadiserverrc, add a section called "[General]", and for that section add an entry "ExternalPayload=true", then restart the akonadi server (akonadictl stop + akonadictl start).
Comment 10 Thomas McGuire 2010-07-22 12:45:03 UTC
Btw, please file separate bug reports for separate issues. This one is about the external file storage.
Comment 11 Alejandro Nova 2010-07-29 09:14:28 UTC
I can't, because I'm really thinking that all my troubles depend on this bug. So I'll wait until Beta 2, I'll apply this configuration option and I'll try again to migrate everything to KMail 2 / Akonadi. If I keep getting issues with KMail 2 Migrator and the Akonadi stack, I'll file separate bug reports and ask you to close the ones solved as RESOLVED - FIXED.

I'm waiting for you :).
Comment 12 Volker Krause 2010-07-30 11:27:49 UTC
SVN commit 1157128 by vkrause:

Backport enabling of FS store.

BUG: 243775


 M  +1 -1      dbconfig.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1157128
Comment 13 Alejandro Nova 2010-08-12 06:03:16 UTC
Fix confirmed! (Beta 2). Thank you :)
Comment 14 Alejandro Nova 2010-09-02 05:45:59 UTC
*** Bug 243674 has been marked as a duplicate of this bug. ***
Comment 15 Volker Krause 2010-10-23 23:59:40 UTC
commit 3342881137488c2a3be173f917f05b2a3649342f
branch refs/tags/v1.4.0
Author: Volker Krause <vkrause@kde.org>
Date:   Fri Jul 30 09:29:13 2010 +0000

    Backport enabling of FS store.
    
    BUG: 243775
    
    svn path=/branches/akonadi/1.4/; revision=1157128

diff --git a/server/src/storage/dbconfig.cpp b/server/src/storage/dbconfig.cpp
index 4d4946d..f8c4e67 100644
--- a/server/src/storage/dbconfig.cpp
+++ b/server/src/storage/dbconfig.cpp
@@ -47,7 +47,7 @@ DbConfig::DbConfig()
   if ( mSizeThreshold < 0 )
     mSizeThreshold = 0;
 
-  mUseExternalPayloadFile = false;
+  mUseExternalPayloadFile = true;
   mUseExternalPayloadFile = settings.value( QLatin1String( "General/ExternalPayload" ), mUseExternalPayloadFile ).toBool();
 }