Upgrade issue from OJS 3.3.20 to 3.4.8: ‘Table already exists’ loop
Hi,
I’m currently experiencing a problem when upgrading from OJS 3.3.20 to 3.4.8. My setup is:
Server: CentOS 8
PHP version: 8
MySQL version: 8
The issue arises during the upgrade process with the following error:
ERROR: Upgrade failed: DB: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'failed_jobs' already exists (SQL: create table `failed_jobs` (`id` bigint unsigned not null auto_increment primary key, `connection` text not null, `queue` text not null, `payload` longtext not null, `exception` longtext not null, `failed_at` timestamp default CURRENT_TIMESTAMP not null) default character set utf8 collate 'utf8_general_ci')
Deleting the mentioned table (failed_jobs) results in the upgrade script trying to create another table, which also already exists, causing an infinite loop. I have encountered the same behavior across multiple OJS instances.
Has anyone experienced this issue or found a solution to this specific upgrade loop?
The failed_job table shouldn’t exist in a 3.3.0 database. Did you take a backup before you first attempted to run the upgrade? If so, can you double-check that it contains no failed_jobs table in it?
If the 3.3.0-x database dump doesn’t contain a failed_jobs table, then you’re probably forgetting to drop and re-create the database before running an upgrade.
If the 3.3.0-x database does contain a failed_jobs table, then it suggests that it was taken after the first failed upgrade attempt already happened. If that’s the case, do you have the error message that the first upgrade attempt encountered?
Regards,
Alec Smecher
Public Knowledge Project Team
I’ve rechecked the database backup from the original OJS 3.3.20 installation, and it turns out the failed_jobs table does exist, but it’s completely empty.
Each time I attempted the upgrade, I’ve performed a full MySQL database backup beforehand and restored this clean backup before every new attempt, so the database always starts in the original state (with an empty failed_jobs table).
Unfortunately, I don’t have the log from the original upgrade attempt, but the error consistently repeats as described, creating an infinite loop with various tables indicating they already exist.
Could the presence of an empty failed_jobs table in the original 3.3.20 installation cause the upgrade script to behave this way? Any suggestion on how to proceed?
There is no failed_jobs table in OJS 3.3.0-x or older – it was only introduced in 3.4.0-x. The error you’re getting is caused by the upgrade process trying to create that table, but it already exists.
I have no way of knowing what the history of that installation is, but the most common way we see error messages like this is when folks forget to take a backup first, then attempt and fail an upgrade. When an upgrade fails partway through the process, it leaves the database somewhere between 3.3.0-x and 3.4.0-x. If you know what stage the upgrade failed in, it can be possible to work through the upgrade from there. If you don’t, it’ll take some work to determine what upgrade steps have been completed and what steps still have to execute. It gets really hard if the upgrade has been attempted multiple times, because it’s even less clear what has been run and what has not.
Long story short, you can delete that table before running the upgrade – but it’s likely a symptom, not a cause. I suspect your backup is not truly a clean 3.3.0-x backup.
Regards,
Alec Smecher
Public Knowledge Project Team