EPrints and MySQL 8

From EPrints Documentation
Revision as of 11:18, 6 June 2023 by Drn@ecs.soton.ac.uk (talk | contribs) (Added Not Null without Default Value issue)
Jump to: navigation, search

Various changes have been made to MySQL between version 5.7 and 8 and these can have some impact on EPrints.

Slow Performance

By default EPrints now uses InnoDB as its table engine. As EPrints can make a lot of transactions to update a eprint record whilst in the workflow, as well as complex background tasks this means the default configuration of MySQL makes EPrints rather slower than before. This can be fixed by adding the following line to /etc/mysql/mysql.conf.d/mysqld.cnf:

innodb_flush_log_at_trx_commit=2

What this change does is ensure the logs are flushed once a second rather than after each transaction commit. This is not ideal as your bin logs could potential miss transactions if the database was to crash but does significantly improve the performance of EPrints. Further investigation is required to determine how serious an impact lost transactions from the bin logs would be for EPrints. At worse this would likely affect only a small number of eprints.

Not Null without Default Value

In EPrints a MetaField can set the attribute allow_null => 0. This means strictly it has has to have a default value. Prior to EPrints 3.4.4, default values were not set for MetaField's created with allow_null => 0 and not until EPrints 3.4.5 were the default values tailored depending on the type of database field. MariaDB 10.x also has the same issue.

If you are running an earlier version of EPrints, you could manually alter your database to make sure any MetaFields that have allow_null => 0 and set a default value something like:

 ALTER TABLE `eprint` MODIFY COLUMN `not_null_field` VARCHAR(255) NOT NULL DEFAULT ;

Otherwise, you could change your MySQL server's configruation to overlook this by adding the following to /etc/mysql/mysql.conf.d/mysqld.cnf and restart MySQL:

 sql_mode=ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION