improve exception when creating an index on cf_session_data fails
Description
Environment
None
Attachments
1
- 23 May 2023, 02:11 pm
Activity
Show:
Zac Spitzer 23 May 2023 at 14:11
closing… tested via the testcase for https://luceeserver.atlassian.net/browse/LDEV-215
Zac Spitzer 20 May 2023 at 20:49
Pothys - MitrahSoft 8 November 2022 at 13:40Edited
I've checked this ticket and confirmed the issue happened on the lucee latest version 5.3.9.84-SNAPSHOT. while using the datasource to the session storage, the exception for failing to create a unique index on the table cf_session_data doesn't include the original exception.
I added a fix to this ticket
Pull Request: https://github.com/lucee/Lucee/pull/1871
Stacktrace after the fix
lucee.runtime.exp.DatabaseException: Failed to create unique index on cf_session_data
at lucee.runtime.type.scope.storage.db.Ansi92.select(Ansi92.java:128)
at lucee.runtime.type.scope.storage.IKHandlerDatasource.loadData(IKHandlerDatasource.java:52)
at lucee.runtime.type.scope.storage.IKStorageScopeSupport.getInstance(IKStorageScopeSupport.java:139)
at lucee.runtime.type.scope.ScopeContext.getCFSessionScope(ScopeContext.java:564)
at lucee.runtime.type.scope.ScopeContext.getSessionScope(ScopeContext.java:440)
at lucee.runtime.PageContextImpl.sessionScope(PageContextImpl.java:1440)
at lucee.runtime.PageContextImpl.sessionScope(PageContextImpl.java:1434)
at test.testcases.test_cfm$cf.call(/test/testcases/test.cfm:2)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1027)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:950)
at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:221)
at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44)
.............
.............
Caused by: lucee.runtime.exp.DatabaseException: INDEX command denied to user 'root'@'localhost' for table 'cf_session_data'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:764)
at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:648)
at lucee.runtime.type.util.QueryUtil.execute(QueryUtil.java:325)
at lucee.runtime.type.QueryImpl.execute(QueryImpl.java:295)
at lucee.runtime.type.QueryImpl.<init>(QueryImpl.java:241)
at lucee.runtime.type.QueryImpl.<init>(QueryImpl.java:231)
at lucee.runtime.type.scope.storage.db.Ansi92.select(Ansi92.java:125)
... 41 more
Fixed
Details
Assignee
Pothys - MitrahSoftPothys - MitrahSoftReporter
Zac SpitzerZac SpitzerPriority
NewFix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
None
Details
Details
Assignee
Pothys - MitrahSoft
Pothys - MitrahSoftReporter
Zac Spitzer
Zac SpitzerPriority
Fix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
None
Created 26 October 2022 at 10:22
Updated 23 May 2023 at 14:11
Resolved 23 May 2023 at 14:11
We using database session storage, Lucee will auto create the table and index, however, creating the index may fail due to datasource permissions
https://github.com/lucee/Lucee/blob/5.3/core/src/main/java/lucee/runtime/type/scope/storage/db/Ansi92.java#L125
Currently the detail of the exception is being lost
// database table created, now create index try { sql = new SQLImpl("CREATE UNIQUE INDEX ix_" + tableName + " ON " + tableName + "(cfid, name, expires)"); new QueryImpl(pc, dc, sql, -1, -1, null, scopeName + "_storage"); } catch (DatabaseException _de) { throw new DatabaseException("Failed to create unique index on " + tableName, null, sql, dc); }
Might be good to write out an error to the
scope.log
too, that is less likely to get lost amongst all the other noise inapplication.log
?