Friday, March 11, 2016

Workaround for trouble with updating akonadi tables

I was just updating the Kubuntu packages that move from akonadi 15.08 to 15.12.1 and sadly akonadi failed to migrate with this error


Adding new foreign key constraints
"ALTER TABLE PimItemFlagRelation ADD FOREIGN KEY (PimItem_id) REFERENCES PimItemTable(id) ON UPDATE CASCADE ON DELETE CASCADE"
Updating index failed:
Sql error: Cannot add or update a child row: a foreign key constraint fails (`akonadi`.`#sql-6ea8_3`, CONSTRAINT `#sql-6ea8_3_ibfk_1` FOREIGN KEY (`PimItem_id`) REFERENCES `pimitemtable` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) QMYSQL: Unable to execute query
Query: ALTER TABLE PimItemFlagRelation ADD FOREIGN KEY (PimItem_id) REFERENCES PimItemTable(id) ON UPDATE CASCADE ON DELETE CASCADE
""
Unable to initialize database.

Bug 354536 will be fixed with the akonadi 15.12.3 release next week.

Lucky meanwhile amazing Dan was ready to help me workaround the issue.

You need to start mysql (if that's what you're using as akonadi backend)
mysqld --defaults-file=$HOME/.local/share/akonadi/mysql.conf --datadir=$HOME/.local/share/akonadi/db_data --socket=/tmp/akonadi-mysql.socket

then connect to it
mysql -S /tmp/akonadi-mysql.socket

And run a series of sql commands
http://paste.ubuntu.com/15344766/

After that shut down mysql
mysqladmin -S /tmp/akonadi-mysql.socket shutdown

And start akonadi and you should be golden again
akonadictrl start

3 comments:

Anonymous said...

After the last updates done on Kubuntu Xenial, Kmail won't start. I'm getting this error:

kmail: symbol lookup error: /usr/lib/x86_64-linux-gnu/libKF5AkonadiCore.so.5: undefined symbol: _ZTIN7Akonadi8Protocol7CommandE

Any ideas how to solve it?

Albert Astals Cid said...

Yes, that is unfortunately happening due to the way source packages are built one at a time, uploaded to proposed and then moved to the main repos with "too much granularity", so basically you have some akonadi packages that are new and some that are old.

I solved that installing the kubuntu-ppa/staging-misc ppa
sudo add-apt-repository ppa:kubuntu-ppa/staging-misc

At this moment it has all the packages that should end up in xenial.

When xenial is "right" again (that's hard to say how to measure, but i guess you can do a dpkg -l and check that not many packages with the version containing ubuntu1~ubuntu16.04 are installed) you should use ppa-purge to clean the ppa from your system in case it brings something bad later on.

Anonymous said...

Thanks for your interest but this trick with a staging ppa did not do its job.