Kontact: mysql.err flooded with error messages

Hi,

The files ~/.local/share/akonadi/db_data/mysql.err and mysql.err.old are flooded with error messages like this:

2021-01-31 10:21:35 11 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'min_value' at position 3 to have type varbinary(255), found type varchar(255).
2021-01-31 10:21:35 11 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'max_value' at position 4 to have type varbinary(255), found type varchar(255).
2021-01-31 10:21:35 11 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'min_value' at position 3 to have type varbinary(255), found type varchar(255).
2021-01-31 10:21:35 11 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'max_value' at position 4 to have type varbinary(255), found type varchar(255).
2021-01-31 10:21:35 11 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'min_value' at position 3 to have type varbinary(255), found type varchar(255).
2021-01-31 10:21:35 11 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'max_value' at position 4 to have type varbinary(255), found type varchar(255).
2021-01-31 10:21:35 11 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'min_value' at position 3 to have type varbinary(255), found type varchar(255).
2021-01-31 10:21:35 11 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'max_value' at position 4 to have type varbinary(255), found type varchar(255).
2021-01-31 10:21:35 11 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'min_value' at position 3 to have type varbinary(255), found type varchar(255).
2021-01-31 10:21:35 11 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'max_value' at position 4 to have type varbinary(255), found type varchar(255).

The space consumption goes up to gigabytes. I delete those files from time to time and exempt them from my backup routine, but this long standing error has to be solved. I don’t see any regression in Kontact and KMail, which may be related to this issue.

Best regards,
Bequimão

Looks like column-stats data base is not formatted correctly it is expecting a binary column but finds a varchar column.

Maybe an old database or possible corruption of the column definition. Ask mysql people how to correct.

Yes, it is originally openSUSE 13.2, the first version with btrfs as default filesystem.

Meanwhile I created a test-user, akonadi running without any problem. Of course, it is much work to switch over to the new user.

I managed to correct the table definition as follows - after some tries:

bequimao@linux-91w7:~> mysql akonadi
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysql/mysql.sock' (2)
bequimao@linux-91w7:~> 
bequimao@linux-91w7:~> mysql akonadi --socket=/run/user/1000/akonadi/mysql.socket 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 84
Server version: 10.4.17-MariaDB MariaDB package

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [akonadi]>
MariaDB [akonadi]> desc mysql.column_stats;
+---------------+-----------------------------------------+------+-----+---------+-------+
| Field         | Type                                    | Null | Key | Default | Extra |
+---------------+-----------------------------------------+------+-----+---------+-------+
| db_name       | varchar(64)                             | NO   | PRI | NULL    |       |
| table_name    | varchar(64)                             | NO   | PRI | NULL    |       |
| column_name   | varchar(64)                             | NO   | PRI | NULL    |       |
| min_value     | varchar(255)                            | YES  |     | NULL    |       |
| max_value     | varchar(255)                            | YES  |     | NULL    |       |
| nulls_ratio   | decimal(12,4)                           | YES  |     | NULL    |       |
| avg_length    | decimal(12,4)                           | YES  |     | NULL    |       |
| avg_frequency | decimal(12,4)                           | YES  |     | NULL    |       |
| hist_size     | tinyint(3) unsigned                     | YES  |     | NULL    |       |
| hist_type     | enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') | YES  |     | NULL    |       |
| histogram     | varbinary(255)                          | YES  |     | NULL    |       |
+---------------+-----------------------------------------+------+-----+---------+-------+
11 rows in set (0,001 sec)

MariaDB [akonadi]>
MariaDB [akonadi]> alter table mysql.column_stats modify column min_value varbinary(255);
Query OK, 0 rows affected (0,350 sec)
Records: 0  Duplicates: 0  Warnings: 0

MariaDB [akonadi]> alter table mysql.column_stats modify column max_value varbinary(255);
Query OK, 0 rows affected (0,096 sec)
Records: 0  Duplicates: 0  Warnings: 0

MariaDB [akonadi]> desc mysql.column_stats;
+---------------+-----------------------------------------+------+-----+---------+-------+
| Field         | Type                                    | Null | Key | Default | Extra |
+---------------+-----------------------------------------+------+-----+---------+-------+
| db_name       | varchar(64)                             | NO   | PRI | NULL    |       |
| table_name    | varchar(64)                             | NO   | PRI | NULL    |       |
| column_name   | varchar(64)                             | NO   | PRI | NULL    |       |
| min_value     | varbinary(255)                          | YES  |     | NULL    |       |
| max_value     | varbinary(255)                          | YES  |     | NULL    |       |
| nulls_ratio   | decimal(12,4)                           | YES  |     | NULL    |       |
| avg_length    | decimal(12,4)                           | YES  |     | NULL    |       |
| avg_frequency | decimal(12,4)                           | YES  |     | NULL    |       |
| hist_size     | tinyint(3) unsigned                     | YES  |     | NULL    |       |
| hist_type     | enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') | YES  |     | NULL    |       |
| histogram     | varbinary(255)                          | YES  |     | NULL    |       |
+---------------+-----------------------------------------+------+-----+---------+-------+
11 rows in set (0,001 sec)

MariaDB [akonadi]>

So I got subsequent faults

Version: '10.4.17-MariaDB'  socket: '/run/user/1000/akonadi/mysql.socket'  port: 0  MariaDB package
2021-01-31 14:13:39 0 [Note] InnoDB: Buffer pool(s) load completed at 210131 14:13:39
2021-01-31 14:13:39 9 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
2021-01-31 14:13:39 9 [ERROR] InnoDB: Column last_update in table `mysql`.`innodb_table_stats` is INT UNSIGNED NOT NULL but should be BINARY(4) NOT NULL (type mismatch).
2021-01-31 14:13:39 9 [ERROR] InnoDB: Fetch of persistent statistics requested for table `akonadi`.`collectionattributetable` but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.
2021-01-31 14:13:39 9 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
2021-01-31 14:13:39 9 [ERROR] InnoDB: Column last_update in table `mysql`.`innodb_table_stats` is INT UNSIGNED NOT NULL but should be BINARY(4) NOT NULL (type mismatch).
2021-01-31 14:13:39 9 [ERROR] InnoDB: Fetch of persistent statistics requested for table `akonadi`.`collectionmimetyperelation` but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.
2021-01-31 14:13:39 9 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
2021-01-31 14:13:39 9 [ERROR] InnoDB: Column last_update in table `mysql`.`innodb_table_stats` is INT UNSIGNED NOT NULL but should be BINARY(4) NOT NULL (type mismatch).
2021-01-31 14:13:39 9 [ERROR] InnoDB: Fetch of persistent statistics requested for table `akonadi`.`collectionpimitemrelation` but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.
2021-01-31 14:13:39 9 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
2021-01-31 14:13:39 9 [ERROR] InnoDB: Column last_update in table `mysql`.`innodb_table_stats` is INT UNSIGNED NOT NULL but should be BINARY(4) NOT NULL (type mismatch).
2021-01-31 14:13:39 9 [ERROR] InnoDB: Fetch of persistent statistics requested for table `akonadi`.`collectiontable` but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.
2021-01-31 14:13:39 9 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
2021-01-31 14:13:39 9 [ERROR] InnoDB: Column last_update in table `mysql`.`innodb_table_stats` is INT UNSIGNED NOT NULL but should be BINARY(4) NOT NULL (type mismatch).
2021-01-31 14:13:39 9 [ERROR] InnoDB: Fetch of persistent statistics requested for table `akonadi`.`flagtable` but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.

It looks like a script mysql_upgrade was not started or faulted. Got this right, too.

bequimao@linux-91w7:~> /usr/bin/mysql_upgrade --user=akonadi --socket=/run/user/1000/akonadi/mysql.socket 
Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats                                 OK
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.gtid_slave_pos                               OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.index_stats                                  OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.roles_mapping                                OK
mysql.servers                                      OK
mysql.table_stats                                  OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Upgrading from a version before MariaDB-10.1
Phase 2/7: Installing used storage engines
Checking for tables with unknown storage engine
Phase 3/7: Fixing views
Phase 4/7: Running 'mysql_fix_privilege_tables'
Phase 5/7: Fixing table and database names
Phase 6/7: Checking and upgrading tables
Processing databases
akonadi
akonadi.collectionattributetable                   OK
akonadi.collectionmimetyperelation                 OK
akonadi.collectionpimitemrelation                  OK
akonadi.collectiontable                            OK
akonadi.flagtable                                  OK
akonadi.mimetypetable                              OK
akonadi.parttable                                  OK
akonadi.parttypetable                              OK
akonadi.pimitemflagrelation                        OK
akonadi.pimitemtable                               OK
akonadi.pimitemtagrelation                         OK
akonadi.relationtable                              OK
akonadi.relationtypetable                          OK
akonadi.resourcetable                              OK
akonadi.schemaversiontable                         OK
akonadi.tagattributetable                          OK
akonadi.tagremoteidresourcerelationtable           OK
akonadi.tagtable                                   OK
akonadi.tagtypetable                               OK
information_schema
performance_schema
test
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
bequimao@linux-91w7:~>

Greetings,
Bequimão

Ok MySQL or mariaDB??? If original is MySQLare yo now running it on MariaDB??? It is best to export from MySQL and Import into MariaDB since you are coming from such an old version.

It is MariaDB. This is the actual file content of mysql.err:

2021-01-31 16:15:06 0 [Note] InnoDB: Using Linux native AIO
2021-01-31 16:15:06 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-01-31 16:15:06 0 [Note] InnoDB: Uses event mutexes
2021-01-31 16:15:06 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-01-31 16:15:06 0 [Note] InnoDB: Number of pools: 1
2021-01-31 16:15:06 0 [Note] InnoDB: Using SSE2 crc32 instructions
2021-01-31 16:15:06 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2021-01-31 16:15:06 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-01-31 16:15:06 0 [Note] InnoDB: Completed initialization of buffer pool
2021-01-31 16:15:06 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-01-31 16:15:07 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2021-01-31 16:15:07 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-01-31 16:15:07 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-01-31 16:15:07 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-01-31 16:15:07 0 [Note] InnoDB: 10.4.17 started; log sequence number 13494324216; transaction id 25102777
2021-01-31 16:15:07 0 [Note] InnoDB: Loading buffer pool(s) from /home/bequimao/.local/share/akonadi/db_data/ib_buffer_pool
2021-01-31 16:15:07 0 [Note] Plugin 'FEEDBACK' is disabled.
2021-01-31 16:15:07 0 [Note] Reading of all Master_info entries succeeded
2021-01-31 16:15:07 0 [Note] Added new Master_info '' to hash table
2021-01-31 16:15:07 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.4.17-MariaDB'  socket: '/run/user/1000/akonadi/mysql.socket'  port: 0  MariaDB package
2021-01-31 16:15:11 0 [Note] InnoDB: Buffer pool(s) load completed at 210131 16:15:11

I started some time ago and after this action $ akonadictl fsck and $ akonadictl vacuum without any error. So the user tables seem ok. The issue was about system tables.

Bequimão

Yes my point is that if you used the same MySQL data files in MariaDB they may not be compatible. If you start a clean MariaDB and import the MySQL data it should work.

Of course, there where several so-called migrations in the past. Anyhow, no more error messages can be found. Kontact/KMail/Akonadi is working fine. The issue is resolved!

Thanks,
Bequimão