matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.89k stars 2.65k forks source link

[Bug] Matomo could not be updated to version 5.0.0 #21725

Closed evaso closed 10 months ago

evaso commented 10 months ago

matomo_error

What happened?

I received a message that a new Matomo version is available and I should install it. When I clicked "Update" a new message appeared: Database Upgrade Required Your Matomo database is out-of-date, and must be upgraded before you can continue. Matomo database will be upgraded from version 5.0.0-rc2 to the new version 5.0.0.

Execute on Piwik-Database (mariadb) Server version: 11.0.2-MariaDB --- dru run--- ALTER TABLE matomo_user ADD COLUMN ts_changes_shown TIMESTAMP NULL; ERROR 1025 (HY000): Error on rename of './piwik/matomo_user' to './piwik/#sql-backup-73d0-109f9be' (errno: 168 "Unknown (generic) error from engine")

ALTER TABLE matomo_log_conversion MODIFY COLUMN pageviews_before SMALLINT UNSIGNED DEFAULT NULL; Query OK, 0 rows affected (0.004 sec) Records: 0 Duplicates: 0 Warnings: 0 --- End of dry run ---

Final report: ERROR [08:58:43] 25013 Uncaught exception: /var/www/matomo/plugins/CoreUpdater/Commands/Update.php(267): Matomo could not be updated! See above for more information. [Query: , CLI mode: 1]

What should happen?

We use MariaDB as a database server (version: 11.0.2). On November 29th I was able to install the update to version 4.16.0 automatically without any problems. The update to version 5.0.0 doesn't work and I can't even reset the whole thing. Access to the account is no longer possible. I always get the message "The database needs to be updated" on the website. What's next? If the update is not possible, how can I at least use the old Matomo version?

How can this be reproduced?

Matomo is installed on our own Linux server.

Matomo version

4.16.0

PHP version

PHP 8.1.12

Server operating system

Ubuntu Server 18.04 LTS

What browsers are you seeing the problem on?

No response

Computer operating system

No response

Relevant log output

No response

Validations

sgiehl commented 10 months ago

Hey @evaso Sorry to hear you have trouble updating Matomo. SQL Error 168 can happen when the disc space is full. Would you mind checking if there is enough free space for the database?

evaso commented 10 months ago

Hi @sgiehl

Unfortunately, this is not the case. There is enough hard drive space available. df -h Filesystem Size Used Avail Use% Mounted on /root 491G 140G 331G 30% /

sgiehl commented 10 months ago

Would you try to execute that statement directly on the database? Wondering if that would work.

evaso commented 10 months ago

What I wrote above in the issue came directly from the Linux console. I entered the commands directly into the database.

mneudert commented 10 months ago

Hi @evaso, could you additionally check to make sure your DB server has not run out of inodes (df -i)?

As the 168 error code is quite generic the mysql error log may be of help. There should be a more helpful log message, something like InnoDB: Operating system error..., detailing if you are experiencing a space/permission/other issue.

_The log file location should be displayed ny SELECT @@GLOBAL.log_error; if you need to search for it._

evaso commented 10 months ago

I restarted the MariaDB server and tried to update Matomo again so that the messages are logged. Then I looked in the log files and didn't necessarily find anything directly related to the Matomo update. I have attached the log file here. mariadb_log.txt mariadb_defaults.txt df-i.txt

mneudert commented 10 months ago

The error lines for innodb_table_stats could be indirectly related:

The drupal issue matches the problem: an ALTER TABLE statement resulting in rename x to x/#backup and Error 168. Comment number 5 solved the issue for someone, probably by running mysql_upgrade mentioned in the second link.

After creating a backup of your database (!), could you check if that also works for you?

evaso commented 10 months ago

I executed the command “mysql_upgrade” and every line was acknowledged with “OK”. The final result was also “OK”. However, this did not bring any changes to the Matomos update. The error message remains the same.

Can't I go back to Matomo version 4.16? That would be enough for me for now. Currently I can't do anything with matomo anymore.

evaso commented 10 months ago

The problem has now been solved. I installed the current update of Mariadb (11.0.3-MariaDB, previously version was 11.0.2) and then I successfully executed the Matomo update. 😅 Thanks for the support!