SUMMARY After switching to IMAP akonadi fsck reports thousands of messages `Item "....." has no RID.` as well as that one item is dirty . Is there any procedure to clean up the akonadi mysql data base to get rid of those messagews ? It seems that akonadi handles the connection to mysql . How a user can access akonadi mysql database and run any solutions KDE team suggets ? STEPS TO REPRODUCE 1. at will wunning akonadictl fsck 2. 3. OBSERVED RESULT Thousand of Item "....." has no RID. messages Found 3734 items without RID. Item "30024" has RID and is dirty. Found 1 dirty items. EXPECTED RESULT No such messages SOFTWARE/OS VERSIONS Linux/KDE Plasma: leap 15.0 (available in About System) KDE Plasma Version: 5.12.8 KDE Frameworks Version: 5.45.0 Qt Version: ? ADDITIONAL INFORMATION [akonadi fsck/vacuum/status output ] 2019/04/23-18:39:42 ; Start /Common_Bin/akonadi_utils.sh akonadictl fsck Looking for resources in the DB not matching a configured resource... Looking for collections not belonging to a valid resource... Checking collection tree consistency... Looking for items not belonging to a valid collection... Looking for item parts not belonging to a valid item... Looking for item flags not belonging to a valid item... Looking for overlapping external parts... Verifying external parts... Found 5906 external files. Found 5906 external parts. Found no unreferenced external files. Checking size treshold changes... Found 0 parts to be moved to external files Found 0 parts to be moved to database Looking for dirty objects... Collection "Search" (id: 1) has no RID. Collection "OpenInvitations" (id: 151) has no RID. Collection "DeclinedInvitations" (id: 152) has no RID. Collection "Import_from_archive" (id: 160) has no RID. Found 4 collections without RID. Item "28761" has no RID. ..... Item "33803" has no RID. Item "33804" has no RID. Item "38264" has no RID. Found 3734 items without RID. Item "30024" has RID and is dirty. Found 1 dirty items. Looking for rid-duplicates not matching the content mime-type of the parent collection Checking Local Folders Checking Notes Checking Personal Calendar Checking Search Checking ndordea@IMAP Checking DeclinedInvitations Checking OpenInvitations Checking Alarm_Templates ..... Migrating parts to new cache hierarchy... Checking search index consistency... Skipping virtual Collection 1 Checking Collection 2 search index... Checking Collection 3 search index... Checking Collection 4 search index... ..... Checking Collection 150 search index... Skipping virtual Collection 151 Skipping virtual Collection 152 Checking Collection 153 search index... .... Checking Collection 255 search index... Flushing collection statistics memory cache... Consistency check done. akonadictl vacuum vacuuming database, that'll take some time and require a lot of temporary disk space... optimizing table SchemaVersionTable... optimizing table ResourceTable... optimizing table CollectionTable... optimizing table MimeTypeTable... optimizing table PimItemTable... optimizing table FlagTable... optimizing table PartTypeTable... optimizing table PartTable... optimizing table CollectionAttributeTable... optimizing table TagTypeTable... optimizing table TagTable... optimizing table TagAttributeTable... optimizing table TagRemoteIdResourceRelationTable... optimizing table RelationTypeTable... optimizing table RelationTable... optimizing table PimItemFlagRelation... optimizing table PimItemTagRelation... optimizing table CollectionMimeTypeRelation... optimizing table CollectionPimItemRelation... vacuum done akonadictl status Akonadi Control: running Akonadi Server: running Akonadi Server Search Support: available (Remote Search) Available Agent Types: akonadi_akonotes_resource, akonadi_archivemail_agent, akonadi_birthdays_resource, akonadi_contacts_resource, akonadi_davgroupware_resource, akonadi_ews_resource, akonadi_ewsmta_resource, akonadi_facebook_resource, akonadi_followupreminder_agent, akonadi_googlecalendar_resource, akonadi_googlecontacts_resource, akonadi_ical_resource, akonadi_icaldir_resource, akonadi_imap_resource, akonadi_indexing_agent, akonadi_invitations_agent, akonadi_kalarm_dir_resource, akonadi_kalarm_resource, akonadi_knut_resource, akonadi_kolab_resource, akonadi_maildir_resource, akonadi_maildispatcher_agent, akonadi_mailfilter_agent, akonadi_mbox_resource, akonadi_migration_agent, akonadi_mixedmaildir_resource, akonadi_newmailnotifier_agent, akonadi_notes_agent, akonadi_notes_resource, akonadi_openxchange_resource, akonadi_pop3_resource, akonadi_sendlater_agent, akonadi_tomboynotes_resource, akonadi_vcard_resource, akonadi_vcarddir_resource 2019/04/23-18:40:06 ; /Common_Bin/akonadi_utils.sh ... has completed .
I did a little bit of work with akonadi database and realized that all items with remoteId null are in pimitemtable with references to parttable and pimitemflagrelation , I got to akonadi database via sokket then issued the commands : select "akonadi database status of NULL RemoteId before clean up "; select count(*) from akonadi.pimitemtable where remoteId is NULL ; select count(*) from akonadi.parttable where pimItemId in ( select id from pimitemtable where remoteId is null ) ; select count(*) from akonadi.pimitemflagrelation where PimItem_id in ( select id from pimitemtable where remoteId is null ) ; -- delete from akonadi.pimitemflagrelation where PimItem_id in ( select id from pimitemtable where remoteId is null ) ; delete from akonadi.parttable where pimItemId in ( select id from pimitemtable where remoteId is null ) ; delete from akonadi.pimitemtable where remoteId is NULL ; -- select "akonadi database status of NULL RemoteId after clean up "; select count(*) from akonadi.pimitemtable where remoteId is NULL ; select count(*) from akonadi.parttable where pimItemId in ( select id from pimitemtable where remoteId is null ) ; select count(*) from akonadi.pimitemflagrelation where PimItem_id in ( select id from pimitemtable where remoteId is null ) ; After that the akonadictl fsck appears clean .
Nick, thank you for your report. I can confirm that this is happening. You may clear up the fsck messages about "item has no RID" with the queries you stated, however… as far as I understand Akonadi assigns a RID once it stored the item in remote storage. For IMAP this would be the IMAP account and for Maildir resource it would be the Maildir. And right now Akonadi's change recorder has no means to retry this failed operation. So items may never end up in the remote storage! Additionally for Maildir I do not get how this operation to store into (the quite local) remote storage could ever fail, as long as the filesystem has enough space. So it could be that those items without RID have not yet been stored to the remote storage and that by deleting them from the database (and if payload stored externally from 'file_db_data') you loose those items (mails, events, contacts, …). So there is a real potential for data loss there. However it also could be that Akonadi just messes up big time like in storing the items into remote storage, but somehow failing to store the remote ID or whatever. I just recently switched from MariaDB to PostgreSQL and already got "Found 43 items without RID." as well as "Moved 6882 unreferenced files to lost+found." (will do a separate bug report about that, since it actually did not even move those files), after just a few weeks of usage. This is with POP3 filling maildir. One thing: On delays during background jobs I sometimes just did "akonadictl stop" and then as PostgreSQL is not stopped completely on my system (yet another bug report), also stop the PostgreSQL process, so this may contribute to the situation. Did you do something similar at times?
Hello Martin, Thank you for your email and your comments . I agree that some emails may be lost . I took the time to try making/finding some correlations with what the user sees . ----- First of all I converted to IMAP as per ip provider's tech-support . So the database contains records from the "old" [maildir? ] system and the new "IMAP" system . Also I had to move the database from my old machine to a new one [ in fact entire /home from old was transfered to the new machine ] So the same userid had acceess to the emails immediately after opensuse leap 15.0 was installed on the new machine ]. I do not know if these changes have any impact [ the hostname was chaged ] ----- Based on the way akonadictl presents its resulst it(akonadictl) is NOT a user friendly tool . On the contrary the actual reporting scares the user with those messages "no RID" or "dirty" or "records removed from data base and moved in lost-and-found" without at least to ask the user if [s]he wants/agrees with that move . I looked closely to pimitemtable and it seems that the column remoteId is nullable [ i.e. accepts an undefinned/unidentified/unknowm value ]. I believe that the hub of all these issues is not with the database server but with akonadi because switching between MariaDB and Postgresql does not stop the isses from happening. These problems in kmail-database are inherited from the time when kmail was using sqlite . In my humble opinion, the database server does what is told/comanded by the interface between the user and the database---that is akonadi---. It is strange that a such important item as remoteId was translated in a datamodel that accepts it as being nullable . That allows that any event that is not controlled by the code inserts/updates a record as having remoteId NULL, and from this all users' complaints . This assumption does not match the reality . I would like to know how it comes that receiving an email---which has a sender and a receiver--- is recorded in the database with a remoteId of NULL value ? I provide below some info collected from my machine before c;eaning up the records with RID NULl in pimitemtable . You van notice that that record had a valid collectionId but has invalid remoteId . I checked that many other emails with valid remoteId pointer to the same collection Id . I tend to agree with you that ..... `` However it also could be that Akonadi just messes up big time like in storing the items into remote storage, but somehow failing to store the remote ID or whatever. `` I believe that KDE development should have a look at kmail-database-datamodel if it matches technical-requirements and/or ifv akonadi handles the email requests properly . Also it is very dificult for the user to find any item that is wrong using kmail and not to dig in databse tables . That's the role of akonadictl and/or what ever any USER ORIENTED tools . I believe that akonadikconsole is too powerful for the casual user . At the same time akonadi&kmail seem to keep their cards close to the vest ..... making easy for developers to point to user errors . The users have had it for too long asking and asking and asking and nothing to be done . Thank you, Nick ========================= info from my machine ========================= -------------- describe pimitemtable -------------- Field Type Null Key Default Extra id bigint(20) NO PRI NULL auto_increment rev int(11) NO 0 remoteId varbinary(255) YES MUL NULL remoteRevision varbinary(255) YES NULL gid varbinary(255) YES MUL NULL collectionId bigint(20) YES MUL NULL mimeTypeId bigint(20) YES MUL NULL datetime timestamp NO current_timestamp() atime timestamp NO current_timestamp() dirty tinyint(1) YES NULL size bigint(20) NO 0 -------------- select count(*) from pimitemtable -------------- count(*) 8691 Record without RID as reported by akonadictl fsck [ 38264 item ... RID ] 38264 5 NULL NULL NULL 123 4 2019-04-05 01:12:16 2019-04-05 01:12:16 1 81206 collectionId 123 is one of directories under "Local Folders -------------- describe pimitemflagrelation -------------- Field Type Null Key Default Extra PimItem_id bigint(20) NO PRI NULL Flag_id bigint(20) NO PRI NULL -------------- select count(*) from pimitemflagrelation -------------- count(*) 13859 Records associated with id 38264 [ from pimitemtable ] 38264 1 38264 5 38264 12 38264 13 -------------- describe parttable -------------- Field Type Null Key Default Extra id bigint(20) NO PRI NULL auto_increment pimItemId bigint(20) NO MUL NULL partTypeId bigint(20) NO MUL NULL data longblob YES NULL datasize bigint(20) NO NULL version int(11) YES 0 storage tinyint(4) YES 0 -------------- select count(*) from parttable -------------- count(*) 30569 Records associated with id 38264 [ from pimitemtable ] 131077 38264 5 131077_r2 80258 1 1 131078 38264 6 X-Virus-Flag: no\nX-Virus-Flag: no\nFrom: ......\nTo: .......\nSubject: Fwd: Your ...... . 497 1 0 131079 38264 7 \0\0\0\0\0.... 451 2 0 131080 38264 8 \0\0\0*\0n\0d\0o\0r\0d.... 104 0 0 131081 38264 9 immediately 11 0 0 131082 38264 10 \0\0\0˰\0\0\0˰\0\0\0\0˰\0\0\0˰\02\0\0\0˰\0\0\0\0\0\0\0�X 32 0 0 131083 38264 11 moveTo5 7 0 0 131084 38264 12 97585928 8 0 0
Nick, which version are you testing on? Do you use KDEPIM 18.12 or later by chance? If so could you please update the version number to the output of 'akonadictl --version'?
Martin, akonadictl version is 5.7.3 kdepim is at level 17.12.3 The levels of all akonadi/kmail/etc installed software and the reports od akonadictl fsck| vacuum are provided as attachments. After the "remoteId is NULL" cleanup I noticed that all those annoyng messages "wait until ..." are gone . I checked my email at the interner provider server and there are no emails there . The IP tech support told me that with IMAP after an email is received by the client[laptop] it is deleted from the server . So I did not understand why the kmail client was checking remote server . Now it appears that kmail/akonadi tries to solve that NULL remoteId . akonadictl fsck's message ' Item "28761" has no RID.' is wrong . That item with id=28761 HAS an RID but its value is set to NULL . It is very strange/misleading message and the culprit seems to be akonadictl and/or kmail because they do not interpret correctly database/table/record's contents . Thanks, Nick
Created attachment 119695 [details] akonadi_kmail_kontact_mariadb_installed_software_levels.txt
Created attachment 119696 [details] akonadictl_fsck_vacuum_after_NULL-RID_cleanup.txt
Martin, After the "remoteId is null" clean I tried to import some records/messages that had "remoteId" issues [ based on pimitemtable I found out their associated collectionid [ i.e. a dir under Local Folders ]. The import was done into a new folder called "Import_from_archive" . It went fine and it created the entire folder stuctures existing under "Inbox" . Then I MOVED the contents of the imported emails into the old folder . After that everything under the folder "Import_from_archive" was deleted . Stop kmail , start kmail the issue akonadictl fsck .... Gues what ? The "Item has not RID" was back . Cleaned the null RIDs again and repeat the import ..... The only diffrence was to COPY from imported structure in the old structure . Stop kmail , start kmail the issue akonadictl fsck .... Gues what ? No "Item has not RID" !!! That means thet the move is a physical move of data whereas copy involves some logical processing that recreaates the messages/records . With this procedure I am very confident that only a few emails were lost . I do not know who's doing the move and who's doing the copy . Thanks, Nick