OJS 3.5.0‑5 installing problem

Just would like to report this error. Search gives a lot of posts about key exceeding the 1000‑byte limit, but this problem still exists from long time ago:

A database error has occurred:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
(SQL: alter table usage_stats_total_temporary_records
add index ust_load_id_context_id_ip_ua_url
(load_id, context_id, ip, user_agent, canonical_url))

  1. It appeared during installation of OJS 3.5.0‑5

  2. On Namecheap shared hosting

  3. Using MariaDB 11.x

  4. And it happened because the installer tried to create a composite index across 5 UTF‑8 columns, exceeding the 1000‑byte limit.

    Setting Name Setting Value
    OS platform Linux
    PHP version 8.2.35
    Apache version LiteSpeed
    Database driver mysql
    Database server version 11.4.13-MariaDB-cll-lve-log

    Same error happened for OJS 3.4.0-11.
    But the OJS 3.3.0.23 installed without any problem.

Hi Gennady,

The figure in the error is the clue: 1000 bytes is the maximum index length of the MyISAM storage engine. InnoDB allows index keys of up to 3072 bytes (DYNAMIC row format), and MariaDB’s other engine, Aria, was raised to 2000 bytes in 10.5. So on this server the tables are being created as MyISAM.

OJS does not choose a storage engine. In 3.5 the database connection is built from the driver, host, name, user, password, charset and collation only (lib/pkp/classes/core/PKPContainer.php), so every table gets the server’s default_storage_engine.

The index in your error, ust_load_id_context_id_ip_ua_url, covers load_id (50 characters), context_id (a bigint), ip (64), user_agent (255) and canonical_url (255): roughly 1,900 bytes in utf8 or 2,500 in utf8mb4. That is over MyISAM’s limit in either character set and well inside InnoDB’s. 3.3.0-23 installs because these statistics tables and their composite indexes arrived with 3.4.

To confirm, run this in phpMyAdmin (SQL tab):

SHOW VARIABLES LIKE 'default_storage_engine';

If it says MyISAM, ask the host to make InnoDB the default storage engine, then empty the database and run the installer again. Another utf8 collation will not fix it — the limit belongs to the engine.

@smartscholars

Thank you for your help. I’ll keep this in mind when I eventually upgrade to 3.5.

I think the PKP developers should improve the installer to detect the database server and version and handle storage engines accordingly:

  • MySQL: Explicitly use InnoDB.

  • MariaDB: Explicitly use InnoDB.

  • PostgreSQL: Use native PostgreSQL storage (no engine selection required).

This would prevent installation failures caused by hosting providers’ default storage engine configurations.