To resolve this, it seems to be safe to go through the following procedure.
** THIS PROCEDURE IS FOR INSTALLATIONS WITH THE ATTACHMENTS HELD IN THE DATABASE ***
You have two possibilities:
A) leave the MAPI object believe they have an attachement, but when you try to open such, you will get an error message
B) entirely discard the reference to such attachments.
To fix the above error message, method A is sufficient
I would recommend version A, because in this case you get a feedback from Kopano that the attachement is broken. This seems to be better than not knowing at all there used to be an attachment. Additionally, method B is probably incomplete.
PROCEED AT YOUR OWN RISK. I’M NOT A KOPANO SUPPORTER, OR RELATED TO KOPANO OTHER THAN I’M A USER. I CAN NOT BE HELD LIABLE FOR ANY DATA LOSS IF YOU FOLLOW MY INSTRUCTIONS*
MAKE A BACKUP OF YOUR PRODUCTION DATABASE AND FEED IT INTO A TEST SYSTEM. TRY THE PROCEDURE ON THE TEST SYSTEM BEFORE FIXING YOUR PRODUCTION*
do the basic cleanup of the attachments by running
/usr/share/doc/kopano/perl -w db-remove-orphaned-attachments /etc/kopano/server.cfg
Stop kopano server
if you choose method A, delete all records from singleinstances that do not have any records in lob:
delete from singleinstances where instanceid not in (select instanceid from lob);
if you choose method B, delete the records in hierarchy that claim to have an attachement, but the attachment is not in the database:
delete from hierarchy where type=7 and id not in (select hierarchyid from singleinstances);
restart kopano-server
NOTICE: following method B probably leaves other stubs in the databse. It seems to work, but is far from doing a surgery on your data. It’s more like the sledgehammer.