Error trying to execute the migration 'ALTER TABLE
The error was: SQLSTATE: Integrity constraint violation: 1062 Duplicate entry 'AQBqYXZhLnV0aWwuVHJlZU1h8AEBAW9yZy5hcGFjaGUuY29tbW9ucy5iZWFud...' for key 'PRIMARY'
Maybe as a workaround we could delete all expired sessions from the table first? This should minimise the risk.
Overall the risk of this happening is quite low because session Ids are usually much shorter unless maybe customised with https://www.php.net/manual/en/session.configuration.php#ini.session.sid-length and the chance of two similar IDs for the first 190 char is quite low. It's actually so low there must have been some other issue there.
Actually better workaround be to update each SessionID... since we now hash the sessionID, we could iterate over each session and update the ID in the table maybe before running this update. The hash would be for sure less than 190 character and maybe it keeps their session alive as a bonus point?
Deleting the sessions fixed the error as expected: https://forum.matomo.org/t/error-upgrading-db-while-upgrading-to-4-0-0-b1/39478/3