Bug 362580 - akonadi server crashes when recreating the MySQL akonadi database
Summary: akonadi server crashes when recreating the MySQL akonadi database
Status: RESOLVED FIXED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: server (show other bugs)
Version: 5.2.0
Platform: Kubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-02 09:13 UTC by Christoph Pospiech
Modified: 2017-09-09 03:25 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 16.04.2


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Pospiech 2016-05-02 09:13:18 UTC
The akonadi database is maintained on a external MySQL server (/usr/sbin/mysqld).
The error occurs after upgrading to Kubuntu 16.04, which includes upgrading mysql-server-5.6 to mysql-server-5.7 . Assuming the akonadi database schema has changed, I tried to drop the database and recreate it. This crashed when attempting to create the table PimItemTable.

Reproducible: Always

Steps to Reproduce:
1. akonadictl stop
2. mysql -h localhost -u akonadi -p
3. mysql> drop database if exists akonadi;
4. akonadictl start

Actual Results:  
"CREATE TABLE PimItemTable (id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, rev INTEGER NOT NULL DEFAULT 0, remoteId VARBINARY(255), remoteRevision VARBINARY(255), gid VARBINARY(255), collectionId BIGINT, mimeTypeId BIGINT, datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, atime TIMESTAMP, dirty BOOL, size BIGINT NOT NULL DEFAULT 0, FOREIGN KEY (collectionId) REFERENCES CollectionTable(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (mimeTypeId) REFERENCES MimeTypeTable(id) ON UPDATE CASCADE ON DELETE RESTRICT)  COLLATE=utf8_general_ci DEFAULT CHARSET=utf8"
"\nSql error: Invalid default value for 'atime' QMYSQL: Unable to execute query\nQuery: CREATE TABLE PimItemTable (id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, rev INTEGER NOT NULL DEFAULT 0, remoteId VARBINARY(255), remoteRevision VARBINARY(255), gid VARBINARY(255), collectionId BIGINT, mimeTypeId BIGINT, datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, atime TIMESTAMP, dirty BOOL, size BIGINT NOT NULL DEFAULT 0, FOREIGN KEY (collectionId) REFERENCES CollectionTable(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (mimeTypeId) REFERENCES MimeTypeTable(id) ON UPDATE CASCADE ON DELETE RESTRICT)  COLLATE=utf8_general_ci DEFAULT CHARSET=utf8"
Unable to initialize database.
terminating service threads
terminating connection threads
stopping db process
Failed to remove runtime connection config file
Application 'akonadiserver' exited normally...


Expected Results:  
PimItemTable should be created along with all other tables and akonadi server should run.

Work around:
After recreating the above crash, execute the following SQL statements on the mysql command prompt.
Then redo "akonadictl start".
mysql> use akonadi;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>  CREATE TABLE PimItemTable (id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, rev INTEGER NOT NULL DEFAULT 0, remoteId VARBINARY(255), remoteRevision VARBINARY(255), gid VARBINARY(255), collectionId BIGINT, mimeTypeId BIGINT, datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, atime TIMESTAMP DEFAULT CURRENT_TIMESTAMP,  dirty BOOL, size BIGINT NOT NULL DEFAULT 0, FOREIGN KEY (collectionId) REFERENCES CollectionTable(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (mimeTypeId) REFERENCES MimeTypeTable(id) ON UPDATE CASCADE ON DELETE RESTRICT)  COLLATE=utf8_general_ci DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.02 sec)

This is the same SQL statement as in the "Actual Results" tab above, but "DEFAULT CURRENT_TIMESTAMP" added after "atime TIMESTAMP".
Comment 1 Grief 2016-05-12 16:08:14 UTC
Workaround works like a charm! Thank you so much!
Comment 2 Daniel Vrátil 2016-05-15 23:17:09 UTC
Git commit 02555d1695a5b77d2ebead2a982481e1706016ef by Daniel Vrátil.
Committed on 15/05/2016 at 22:53.
Pushed by dvratil into branch 'Applications/16.04'.

Fix MySQL initialization with NO_ZERO_DATE mode

We don't enable NO_ZERO_DATE by default, but external servers may be
configured to use it and will fail to create the PimItemTable in such
case.

Having a default time on atime makes no difference since we already
explicitly set atime to QDateTime::currentDateTime() in the code
when appending a new PimItem.
FIXED-IN: 16.04.2

M  +2    -2    src/server/storage/akonadidb.xml

http://commits.kde.org/akonadi/02555d1695a5b77d2ebead2a982481e1706016ef
Comment 3 Alejandro Espejo 2017-09-09 03:25:58 UTC
Este es el mensaje que me envía:

"EL servicio de gestión de información personal de akonadi no esta funcionando"