Migration indicated as successful but failed?

Hello Matomo team and community.

I tried to update Matomo from 3.14.1 to 4.0.0 but failed.
The table was only updated halfway through, although it showed success on the screen.
The number of MySQL connections was increased to the maximum, but an error occurred.

Executing ALTER TABLE matomo_archive_invalidations ADD COLUMN ts_started DATETIME NULL;… Done. [872 / 876]
Executing ./console plugin:deactivate “ExampleTheme”… Done. [873 / 876]

[X] Error during plugin updates:

* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
* Mysqli prepare error: MySQL server has gone away
The update completed successfuly, however there were issues during the process. Please read the above descriptions for details. For further help:

* Check the [ Matomo FAQ ] which explains most common errors during update. 
* Ask your system administrator - they may be able to help you with the error which is most likely related to your server or MySQL setup.

Matomo has been successfully updated!

Is it possible to update the specs here?

Matomo
version:3.14.1

2 server
reader:m5.large
writer:m5.large

2 RDS
reader:db.r5.12xlarge
writer:db.r5.12xlarge

Number of rows in raw log table
matomo_log_link_visit_action:8,700,000,000
matomo_log_visit:440,000,000

Total number of rows in archive table
numeric:18,000,000
blob:28,000,000
php:7.4.27
mysql:5.7.12

引用

Sometime even i got same error