Skip to content

[Bug] AIAgents: ai_agent_name column not created on wide log_visit tables, core:update hides InnoDB row size error (1118) #23866

@futureweb

Description

@futureweb

What happened?

After updating to Matomo 5.6.1 and enabling the AIAgents plugin, the database migration that should add the ai_agent_name column to matomo_log_visit (formerly piwik_log_visit) reports success in the CLI, but the column is not actually created.

When running:

php /var/www/matomo/console core:update

the output shows something like:

Executing ALTER TABLE `matomo_log_visit` ADD COLUMN `ai_agent_name` VARCHAR(40) NULL;... Done. [1 / 1]

Matomo has been successfully updated!

However, when checking the table structure afterwards, the ai_agent_name column is missing.

Running the same statement manually:

ALTER TABLE `matomo_log_visit` ADD COLUMN `ai_agent_name` VARCHAR(40) NULL;

fails with:

ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126.

So the underlying ALTER TABLE fails due to the InnoDB row size limit, but core:update still reports success and hides the error, leaving the schema in an incomplete state while the AIAgents plugin assumes the column exists.

What should happen?

If the ALTER TABLE fails (e.g. with ERROR 1118: row size too large), core:update should:

  • not print Done and
  • not report Matomo has been successfully updated!.

Instead, the database error should be clearly shown in the CLI output and the update should be marked as failed or at least partially failed. This would avoid having a silently incomplete schema.

Additionally, for migrations on very wide tables like matomo_log_visit, Matomo could:

  • detect or catch InnoDB row size issues, and
  • show a helpful message (for example suggesting ROW_FORMAT=DYNAMIC or restructuring very wide rows) instead of hiding the error.

Right now, the AIAgents plugin ends up in a broken state on large installations: the column is missing, the plugin assumes it is present, and we have to manually debug the problem and perform a heavy operation on a ~30 GB table to fix it.

How can this be reproduced?

This is not reproducible on the public demo because it requires a very large and wide matomo_log_visit table. The issue occurs on a self-hosted installation with:

  • Matomo 5.6.1
  • AIAgents plugin enabled
  • MySQL/MariaDB with InnoDB
  • matomo_log_visit being a very wide table (many columns, including custom dimensions) and ~30 GB in size.

Steps:

  1. Use a Matomo instance with a very wide InnoDB matomo_log_visit table that is close to the InnoDB row size limit (e.g. many VARCHAR columns, large table ~30 GB).

  2. Enable the AIAgents plugin:

    php /var/www/matomo/console core:plugin:activate AIAgents
  3. Run the update:

    php /var/www/matomo/console core:update
  4. Observe that the CLI reports:

    • Executing ALTER TABLE ... ADD COLUMN ai_agent_name ... Done.
    • Matomo has been successfully updated!
  5. Check the schema of matomo_log_visit – the ai_agent_name column is missing.

  6. Execute the migration SQL manually:

    ALTER TABLE `matomo_log_visit` ADD COLUMN `ai_agent_name` VARCHAR(40) NULL;
  7. You will see:

    ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126.
    

This shows that the migration failed at the DB level, but core:update did not surface the error and still reported a successful update.

Matomo version

5.6.1

PHP version

8.3

Server operating system

AlmaLinux

What browsers are you seeing the problem on?

No response

Computer operating system

No response

Relevant log output

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Potential BugSomething that might be a bug, but needs validation and confirmation it can be reproduced.To TriageAn issue awaiting triage by a Matomo core team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions