<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="font-size:1.5em;">On Tuesday, February 7, 2023 6:00:04 AM CST kde-pim-request@kde.org wrote:</span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> I'm using this with a gmx account. I would assume this server is maintained.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> I know nothing about UIDLs. Those duplicated emails cannot be displayed</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> (i.e. when clicking on them nothing happens), they always stay "unread"</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> and I cannot delete them.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I am aware of this problem, and I have a work-around. I added it to the KMail documentation in Section 7, KMail Troubleshooting.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> Is there something I can do to help ?</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Yes. Assuming that you are using mysql (aka mariadb) as your database engine, you can use the mysql program to remove the superfluous database rows. An analogous procedure should work with sqlite, if you're using that instead..</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">First, open a terminal window and find out how many records are lacking RID (remoteid) data:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">~ <span style="color:#0000ff;">$</span> <span style="color:#000000;"><span style="font-family:monospace;"><span style="background-color:#ffffff;">akonadictl fsck 2>&1 | grep ^Found</span></span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 5 external files. </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 5 external parts. </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> no unreferenced external files. </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 0 parts to be moved to external files </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 0 parts to be moved to database </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 6 collections without RID. </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 17 items without RID. </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 0 dirty items.</span></span><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Next, say this:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">~ <span style="color:#0000ff;">$</span> ps ux | grep mysql</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">My system produces the following response:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="background-color:#ffffff;"><span style="color:#000000;">david 16528 0.4 1.1 3412864 180584 ? Sl 08:39 0:07 /usr/sbin/</span><span style="color:#ff5454;"><strong>mysql</strong></span><span style="color:#000000;">d --defaults-file=/home/david/.local/share/ak</span></span><br />onadi/<span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>mysql</strong></span><span style="color:#000000;">.conf --datadir=/home/david/.local/share/akonadi/db_data/ --socket=/run/user/1000/akonadi/</span><span style="color:#ff5454;"><strong>mysql</strong></span><span style="color:#000000;">.socket --pid-file=</span></span><br />/run/user/1000/akonadi/<span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>mysql</strong></span><span style="color:#000000;">.pid </span></span><br />david 17666 0.0 0.0 6692 2136 pts/2 S+ 09:04 0:00 grep --colour=auto <strong><span style="color:#ff5454;"><span style="background-color:#ffffff;">mysql</span></span></strong></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Use the "--socket=" data to invoke the mysql utility program. It will probably come out almost the same on your system ... the big variable is the userid, which is usually 1000 (on a system with just one user, and root).</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">~ <span style="color:#0000ff;">$</span> mysql <span style="color:#000000;"><span style="background-color:#ffffff;">--socket=/run/user/1000/akonadi/mysql.socket</span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">This will start an interactive conversation with the database server.</p>
<p style="margin-top:12;margin-bottom:12;margin-left:0;margin-right:0;"> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="background-color:#ffffff;"><span style="color:#5454ff;"><strong>~ $</strong></span><span style="color:#000000;"> mysql --socket=/run/user/1000/akonadi/mysql.socket </span></span><br />Welcome to the MariaDB monitor. Commands end with ; or \g. <br />Your MariaDB connection id is 57 <br />Server version: 10.6.11-MariaDB Source distribution <br /><br />Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. <br /><br />Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. <br /><br />MariaDB [(none)]> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">You will have to enter three mysql commands (shown below in bold-faced type):</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /><span style="color:#000000;"><span style="background-color:#ffffff;">MariaDB [(none)]> <strong>use akonadi;</strong></span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#000000;"><span style="background-color:#ffffff;">Reading table information for completion of table and column names </span></span><br />You can turn off this feature to get a quicker startup with -A <br /><br />Database changed <br />MariaDB [akonadi]><span style="color:#000000;"><span style="background-color:#ffffff;"> <strong>delete from pimitemtable where remoteid is NULL; </strong></span></span><br />Query OK, 17 rows affected (0.005 sec) <br /><br />MariaDB [akonadi]> <strong>\q</strong></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#000000;"><span style="background-color:#ffffff;">Bye</span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">~#</p>
<p style="margin-top:12;margin-bottom:12;margin-left:0;margin-right:0;"> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">You're now back at the BASH prompt. Verify that the cleanup succeeded:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="background-color:#ffffff;"><span style="color:#5454ff;"><strong>~ $</strong></span><span style="color:#000000;"> akonadictl fsck 2>&1 | grep ^Found </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 5 external files. </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 5 external parts. </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> no unreferenced external files. </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 0 parts to be moved to external files </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 0 parts to be moved to database </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 6 collections without RID. </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 0 items without RID. </span></span><br /><span style="background-color:#ffffff;"><span style="color:#ff5454;"><strong>Found</strong></span><span style="color:#000000;"> 0 dirty items.</span></span><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I should add a few cautions. First, if you have created more than one address book you probably ought to back your address book data up to an external file. Address books in Vcard format are stored directly in the akonadi database, and they do not have an associated remoteid. So the above <strong>delete </strong>command will remove those address book entries -- you'll have to restore the secondary address book from the backup copy. I'm pretty sure that the Vcard address books are the only entities that have no associated remoteid data. Second, you will have to stop KMail (right-click, then say "quit" if it's running in the system tray) and restart it to force reloading of the mysql database files beefore the extraneous entries will go away.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Just a word about why this happens. The basic email data are stored in ~.local/share/local-mail (on most Linux systems). The messages are stored as separate files, with names like 1675709976831.R873.localhost:2,S, where the big long number refers to the time the message was sent, expressed in milliseconds elapsed since 00:00:00 01/01/1970. There's an "akonadi" directory inside ~.local/share -- ~.local/share/akonadi/db_data/akonadi -- that contains the mysql database files. These are basically indexes that contain some metadata, plus pointers to the actual email files in "local-mail". I don't know exactly why, but sometimes, when a message is "filtered" to another folder besides inbox, a job to create the database entry is started more than once. Something goes haywire, and you end up with two database entries that refer to the same message. But only one of them points to the actual email message; the other one contains metadata about the message, but lacks the crucial information saying where to find the actual message.</p>
<p style="margin-top:12;margin-bottom:12;margin-left:0;margin-right:0;"> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> I can remember that building kmail/kdepim was quite some work...</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> Is there maybe some component which I could just try to build to do some</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> debugging ?</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> (I don't even know where to start, kmail, pop3, akonadi, akonadi-agents)</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> Or can I use some tool to find out something about those duplicated emails ?</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> akonadictl, mysql something, or akonadiconsole, something ?</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> Thanks</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> Alex</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">You can learn quite a bit about the database structure underlying akonadi by playing with akonadiconsole. Unfortunately, there's not much documentation for that program. Good luck!</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">-- </p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">David Bryant</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Canyon Lake, Texas </p>
</body>
</html>