Problem upgrading from version 18 to version 20 - oc_filecache

I am currently updating via the terminal from version 18 to version 20, hopping across versions. Whist upgrading from version 19.0.7 to 20.0.5 I keep getting stuck at the following error :

2021-01-16T14:33:34+00:00 Checked for update of app "calendar" in appstore 
2021-01-16T14:33:34+00:00 Repair step: Update name of the stored view
2021-01-16T14:33:34+00:00 Checking for update of app files_accesscontrol in appstore
2021-01-16T14:33:34+00:00 Update app files_accesscontrol from appstore
2021-01-16T14:33:36+00:00 Checked for update of app "files_accesscontrol" in appstore 
2021-01-16T14:33:40+00:00 Repair step: Repair MySQL collation
2021-01-16T14:33:40+00:00 Repair info: All tables already have the correct collation -> nothing to do
2021-01-16T14:33:40+00:00 Repair step: Repair mime types
2021-01-16T14:46:21+00:00 Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'UPDATE `oc_filecache` SET `mimetype` = ? WHERE (`mimetype` <> ?) AND (`mimetype` <> ?) AND (`name`  COLLATE utf8mb4_general_ci LIKE ?)' with params [19, 19, 2, ""]:

SQLSTATE[HY000]: General error: 1206 The total number of locks exceeds the lock table size
2021-01-16T14:46:21+00:00 Update failed
2021-01-16T14:46:21+00:00 Maintenance mode is kept active
2021-01-16T14:46:21+00:00 Resetting log level

When I checked the size of the “oc_filecache” in the database the file is over 46GB in size which seems excessive.

I have tried to run “occ files:scan --all” however I get the following error:

Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade

  There are no commands defined in the "files" namespace. 

Any help would be much appreciated.

Managed to fix this my editing my MariaDB “custom.cnf” file.

I changed the buffer size from 256M to 2048M.

“innodb_buffer_pool_size = 2048M”

I then left my server overnight and it managed to complete the upgrade by the morning.