Table 'xxx' doesn't exist error in Confluence logs when using MySQL
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The Confluence application logs report that one or more Confluence tables don't exist in MySQL database. This error can impact different features in Confluence, depending on the table affected by this error.
Environment
- Confluence Server or Data Center (any version)
- MySQL database
Diagnosis
A MySQLSyntaxErrorException is thrown in <home-directory>/logs/atlassian-confluence.log
.
Here are a couple of examples.
First, this example shows the error as Confluence is trying to record the results of a scheduled task execution:
2020-07-31 07:14:09,752 ERROR [Caesium-1-1] [scheduler.caesium.impl.SchedulerQueueWorker] executeJob Unhandled exception thrown by job QueuedJob[jobId=synchronyStatusCheck,deadline=1596179649748]
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [DELETE FROM scheduler_run_details WHERE start_time < ?]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'confluence2.scheduler_run_details' doesn't exist
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:645)
...
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'confluence2.scheduler_run_details' doesn't exist
at sun.reflect.GeneratedConstructorAccessor307.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2675)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465)
...
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:629)
Here's another example in which Confluence is unable to find certain key tables during startup:
...
2021-09-24 00:35:37,236 WARN [Catalina-utility-1] [confluence.impl.setup.DefaultBootstrapDatabaseAccessor] readValue Unable to determine build number from database. If you are upgrading from a Confluence version prior to 2.3, this is expected.
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'confluence.CONFVERSION' doesn't exist
...
2021-09-24 00:36:11,386 ERROR [Catalina-utility-1] [atlassian.confluence.plugin.BandanaPluginStateStore] load Exception when loading plugins state from the database. Falling back to in memory state.
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'confluence.BANDANA' doesn't exist
In this particular case, similar errors will be found within the Tomcat Catalina log along with the following SEVERE errors:
24-Sep-2021 00:38:15.042 SEVERE [Catalina-utility-1] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file
24-Sep-2021 00:38:15.043 SEVERE [Catalina-utility-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
WARNING: Cannot update an inactive framework.
Confirming the issue in MySQL:
Run the following SQL on your Confluence MySQL database:
-- Query 1: table name in capital letters
select * from CONFVERSION;
-- Query 2: table name in lower case letters
select * from confversion;
You are affected by this issue if:
- Query 1 (upper case) fails and Query 2 (lower case) succeeds.
Cause
Either the table does not exist in the source database or the MySQL instance has case sensitive table names (as it should for Confluence).
Solution
- Verify that the table(s) exist.
- Shutdown Confluence
Backup the Confluence database
- Make sure the Confluence database user and database meet our recommendations that are outlined in Database Setup For MySQL.
- Set the MySQL lower_case_table_names system variable to the value '0' followed by restarting MySQL and Confluence. This particularly applies to Unix based systems as this value should default to 0, per the note below.
Check that MySQL
lower_case_table_names
is set to 0 in Linux and 2 in Windows:show global variables like 'lower_case_table_names';
Check the collation of the Confluence database
-- Substitute <confluence_db_name> with your Confluence database name SELECT default_collation_name FROM information_schema.schemata WHERE schema_name = '<confluence_db_name>';
Generate the Table Rename SQL statements (no changes are made) by running the SQL corresponding to your above database collation:
Please note, the query below will produce a series of
RENAME TABLE
statements, which you must then run against your database.You may not get a row for every table mentioned above.
The number of rows that are returned are dependent on your Confluence version and the Apps installed.
If you get 0 rows returned, you are not affected by the issue described on this KB.
- For the above generated RENAME TABLE SQL statements, manually copy and paste your returned output and run against the Confluence database.
- Once the RENAME TABLES are complete, start Confluence and the
Table 'xxx' doesn't exist
error should be resolved.
If the MySQL server is used by different Atlassian applications, the modification of the lower_case_table_names system variable could cause issues for those other applications. For instance, while this Fisheye KB mentions setting this value to 0, Bamboo MySQL Configuration guide recommends setting this to 1.
MySQL 5.7 Reference Guide
From: https://dev.mysql.com/doc/refman/5.7/en/identifier-case-sensitivity.html:
How table and database names are stored on disk and used in MySQL is affected by the
lower_case_table_names
system variable, which you can set when starting mysqld.lower_case_table_names
can take the values shown in the following table. This variable does not affect case sensitivity of trigger identifiers. On Unix, the default value oflower_case_table_names
is 0. On Windows, the default value is 1. On macOS, the default value is 2.
Value Meaning 0
Table and database names are stored on disk using the lettercase specified in the CREATE TABLE
orCREATE DATABASE
statement. Name comparisons are case-sensitive. You should not set this variable to 0 if you are running MySQL on a system that has case-insensitive file names (such as Windows or macOS). If you force this variable to 0 with--lower-case-table-names=0
on a case-insensitive file system and accessMyISAM
tablenames using different lettercases, index corruption may result.1
Table names are stored in lowercase on disk and name comparisons are not case-sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases. 2
Table and database names are stored on disk using the lettercase specified in the CREATE TABLE
orCREATE DATABASE
statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case-sensitive. This works only on file systems that are not case-sensitive!InnoDB
table names and view names are stored in lowercase, as forlower_case_table_names=1
.