[
https://issues.apache.org/jira/browse/RANGER-4104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17692372#comment-17692372
]
Madhan Neethiraj commented on RANGER-4104:
------------------------------------------
[~andrewluo], [~kirbyzhou] - I was able to reproduce failures in execution of
named query {{XXAuthSession.getRecentAuthFailureCountByLoginId}} using a script
that calls Ranger REST APIs from multiple threads simultaneously with invalid
credentials. I notice at least 3 different types of failures:
1. ArrayOutOfBoundsException
{noformat}
[EL Warning]: 2023-02-22 20:36:40.8--UnitOfWork(729158064)--Exception
[EclipseLink-6168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd):
org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred:
[java.lang.ArrayIndexOutOfBoundsException: 2].
Internal Exception: java.lang.ArrayIndexOutOfBoundsException: 2
Caused by: Exception [EclipseLink-6168] (Eclipse Persistence Services -
2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred:
[java.lang.ArrayIndexOutOfBoundsException: 2].
Internal Exception: java.lang.ArrayIndexOutOfBoundsException: 2
Query: ReportQuery(name="XXAuthSession.getRecentAuthFailureCountByLoginId"
referenceClass=XXAuthSession sql="SELECT COUNT(?) FROM x_auth_sess t0 WHERE
(((t0.LOGIN_ID = ?) AND (t0.AUTH_STATUS <> ?)) AND (t0.CREATE_TIME >
COALESCE((SELECT MAX(t1.CREATE_TIME) FROM x_auth_sess t1 WHERE (((t1.LOGIN_ID =
?) AND (t1.AUTH_STATUS = ?)) AND (t1.CREATE_TIME > ?))),? )))")
at
org.eclipse.persistence.exceptions.QueryException.prepareFailed(QueryException.java:1590)
at
org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:680)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:901)
at
org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)
at
org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:867)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1127)
at
org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:403)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1215)
at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1751)
at
org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
at
org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:517)
... 66 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
at
org.eclipse.persistence.expressions.ListExpressionOperator.getDatabaseStrings(ListExpressionOperator.java:75)
at
org.eclipse.persistence.expressions.ExpressionOperator.printCollection(ExpressionOperator.java:2196)
at
org.eclipse.persistence.internal.expressions.ArgumentListFunctionExpression.printSQL(ArgumentListFunctionExpression.java:99)
at
org.eclipse.persistence.expressions.ExpressionOperator.printDuo(ExpressionOperator.java:2239)
at
org.eclipse.persistence.internal.expressions.CompoundExpression.printSQL(CompoundExpression.java:286)
at
org.eclipse.persistence.internal.expressions.RelationExpression.printSQL(RelationExpression.java:899)
at
org.eclipse.persistence.expressions.ExpressionOperator.printDuo(ExpressionOperator.java:2239)
at
org.eclipse.persistence.internal.expressions.CompoundExpression.printSQL(CompoundExpression.java:286)
at
org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter.translateExpression(ExpressionSQLPrinter.java:306)
at
org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter.printExpression(ExpressionSQLPrinter.java:129)
at
org.eclipse.persistence.internal.expressions.SQLSelectStatement.printSQL(SQLSelectStatement.java:1683)
at
org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.printSQLSelectStatement(DatabasePlatform.java:3178)
at
org.eclipse.persistence.platform.database.MySQLPlatform.printSQLSelectStatement(MySQLPlatform.java:673)
{noformat}
2. NullPointerException
{noformat}
[EL Warning]: 2023-02-22 20:36:40.8--UnitOfWork(305743338)--Exception
[EclipseLink-6168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd):
org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred:
[java.lang.NullPointerException].
Internal Exception: java.lang.NullPointerException
Query: ReportQuery(name="XXAuthSession.getRecentAuthFailureCountByLoginId"
referenceClass=XXAuthSession sql="SELECT COUNT(?) FROM x_auth_sess t0 WHERE
(((t0.LOGIN_ID = ?) AND (t0.AUTH_STATUS <> ?)) AND (t0.CREATE_TIME >
COALESCE((SELECT MAX(t1.CREATE_TIME) FROM x_auth_sess t1 WHERE (((t1.LOGIN_ID =
?) AND (t1.AUTH_STATUS = ?)) AND (t1.CREATE_TIME > ?))),? )))")
Feb 22, 2023 8:36:40 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [REST Service] in context with path []
threw exception
javax.persistence.PersistenceException: Exception [EclipseLink-6168] (Eclipse
Persistence Services - 2.5.2.v20140319-9ad6abd):
org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred:
[java.lang.NullPointerException].
Internal Exception: java.lang.NullPointerException
Caused by: Exception [EclipseLink-6168] (Eclipse Persistence Services -
2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred:
[java.lang.NullPointerException].
Internal Exception: java.lang.NullPointerException
Query: ReportQuery(name="XXAuthSession.getRecentAuthFailureCountByLoginId"
referenceClass=XXAuthSession sql="SELECT COUNT(?) FROM x_auth_sess t0 WHERE
(((t0.LOGIN_ID = ?) AND (t0.AUTH_STATUS <> ?)) AND (t0.CREATE_TIME >
COALESCE((SELECT MAX(t1.CREATE_TIME) FROM x_auth_sess t1 WHERE (((t1.LOGIN_ID =
?) AND (t1.AUTH_STATUS = ?)) AND (t1.CREATE_TIME > ?))),? )))")
at
org.eclipse.persistence.exceptions.QueryException.prepareFailed(QueryException.java:1590)
at
org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:680)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:901)
at
org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)
at
org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:867)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1127)
at
org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:403)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1215)
at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1751)
at
org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
at
org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:517)
... 66 more
Caused by: java.lang.NullPointerException
at java.io.Writer.write(Writer.java:157)
at
org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter.printString(ExpressionSQLPrinter.java:188)
at
org.eclipse.persistence.expressions.ExpressionOperator.printCollection(ExpressionOperator.java:2197)
at
org.eclipse.persistence.internal.expressions.ArgumentListFunctionExpression.printSQL(ArgumentListFunctionExpression.java:99)
at
org.eclipse.persistence.expressions.ExpressionOperator.printDuo(ExpressionOperator.java:2239)
at
org.eclipse.persistence.internal.expressions.CompoundExpression.printSQL(CompoundExpression.java:286)
at
org.eclipse.persistence.internal.expressions.RelationExpression.printSQL(RelationExpression.java:899)
at
org.eclipse.persistence.expressions.ExpressionOperator.printDuo(ExpressionOperator.java:2239)
at
org.eclipse.persistence.internal.expressions.CompoundExpression.printSQL(CompoundExpression.java:286)
at
org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter.translateExpression(ExpressionSQLPrinter.java:306)
at
org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter.printExpression(ExpressionSQLPrinter.java:129)
at
org.eclipse.persistence.internal.expressions.SQLSelectStatement.printSQL(SQLSelectStatement.java:1683)
at
org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.printSQLSelectStatement(DatabasePlatform.java:3178)
at
org.eclipse.persistence.platform.database.MySQLPlatform.printSQLSelectStatement(MySQLPlatform.java:673)
at
org.eclipse.persistence.internal.expressions.SQLSelectStatement.buildCall(SQLSelectStatement.java:782)
at
org.eclipse.persistence.internal.expressions.SQLSelectStatement.buildCall(SQLSelectStatement.java:792)
at
org.eclipse.persistence.descriptors.ClassDescriptor.buildCallFromStatement(ClassDescriptor.java:813)
at
org.eclipse.persistence.internal.queries.StatementQueryMechanism.setCallFromStatement(StatementQueryMechanism.java:390)
at
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareReportQuerySelectAllRows(ExpressionQueryMechanism.java:1696)
{noformat}
3. SQLSyntaxErrorException
{noformat}
[EL Warning]: 2023-02-22 20:36:41.091--UnitOfWork(1275079713)--Exception
[EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd):
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: You have an error in your
SQL syntax; check the manual that corresponds to your MariaDB server version
for the right syntax to use near '))' at line 1
Error Code: 1064
Call: SELECT COUNT(?) FROM x_auth_sess t0 WHERE (((t0.LOGIN_ID = ?) AND
(t0.AUTH_STATUS <> ?)) AND (t0.CREATE_TIME > COALESCE((SELECT
MAX(t1.CREATE_TIME) FROM x_auth_sess t1 WHERE (((t1.LOGIN_ID = ?) AND
(t1.AUTH_STATUS = ?)) AND (t1.CREATE_TIME > ?))),?,))
bind => [7 parameters bound]
Query: ReportQuery(name="XXAuthSession.getRecentAuthFailureCountByLoginId"
referenceClass=XXAuthSession sql="SELECT COUNT(?) FROM x_auth_sess t0 WHERE
(((t0.LOGIN_ID = ?) AND (t0.AUTH_STATUS <> ?)) AND (t0.CREATE_TIME >
COALESCE((SELECT MAX(t1.CREATE_TIME) FROM x_auth_sess t1 WHERE (((t1.LOGIN_ID =
?) AND (t1.AUTH_STATUS = ?)) AND (t1.CREATE_TIME > ?))),?,))")
at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
at
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:682)
at
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
at
org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2002)
at
org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:298)
at
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)
at
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
at
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:299)
at
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:694)
at
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2738)
at
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllReportQueryRows(ExpressionQueryMechanism.java:2675)
at
org.eclipse.persistence.queries.ReportQuery.executeDatabaseQuery(ReportQuery.java:848)
at
org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1127)
at
org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:403)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1215)
at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1751)
at
org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
... 67 more
{noformat}
Different failure types suggest the issue might be due to JPA implementation
that generates queries.
Updating eclipselink library version from 2.5.2 to 2.7.12 (most recent in 2.x
version) seems to resolve this issue. Above failures are not seen using the
same script. I suggest to update eclipselink library version 2.7.12.
> XXAuthSessionDao.getRecentAuthFailureCountByLoginId produces incorrect SQL
> code
> -------------------------------------------------------------------------------
>
> Key: RANGER-4104
> URL: https://issues.apache.org/jira/browse/RANGER-4104
> Project: Ranger
> Issue Type: Bug
> Components: admin
> Affects Versions: 3.0.0, 2.4.0
> Reporter: Andrew Luo
> Priority: Major
> Attachments:
> 0001-Fix-type-of-authWindowStartTime-parameter-in-XXAuthS.patch
>
>
> XXAuthSessionDao.getRecentAuthFailureCountByLoginId produces incorrect SQL
> code due to an error in how the authWindowStartTime Date parameter is bound.
> It is currently bound with setParameter("authWindowStartTime",
> authWindowStartTime) however, [JPA 2.2 Specification Section
> 11.1.53|https://download.oracle.com/otn-pub/jcp/persistence-2_2-mrel-spec/JavaPersistence.pdf]
> says that it should be bound by specifying an additional parameter
> TemporalType.DATE.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)