[ 
https://issues.apache.org/jira/browse/RANGER-3576?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pradeep Agrawal updated RANGER-3576:
------------------------------------
    Summary: service creation is failing intermittently due to DB unique key 
constraint violation  (was: service creation is failing intermittently due to 
MySQLIntegrityConstraintViolationException)

> service creation is failing intermittently due to DB unique key constraint 
> violation
> ------------------------------------------------------------------------------------
>
>                 Key: RANGER-3576
>                 URL: https://issues.apache.org/jira/browse/RANGER-3576
>             Project: Ranger
>          Issue Type: Bug
>          Components: Ranger
>    Affects Versions: 2.0.0, 2.1.0, 3.0.0, 2.2.0, 2.3.0
>            Reporter: Pradeep Agrawal
>            Assignee: Pradeep Agrawal
>            Priority: Major
>             Fix For: 3.0.0, 2.3.0
>
>
> Parallel service creation with the same users in the service config or 
> default policies may fail with following error. 
> {code:java}
> Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value 
> violates unique constraint "x_user_uk_user_name"
>   Detail: Key (user_name)=(rangerlookup) already exists.
>     at 
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532)
>     at 
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267)
>     at 
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312)
>     at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
>     at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
>     at 
> org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:153)
>     at 
> org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:119)
>     at 
> com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:410)
>     at 
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:898)
>     ... 144 more
> 2022-01-04 20:15:45,422 ERROR org.apache.ranger.biz.XUserMgr: Error creating 
> user: rangerlookup
> javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse 
> Persistence Services - 2.7.7.v20200504-69f2c2b80d): 
> org.eclipse.persistence.exceptions.DatabaseException
> Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key 
> value violates unique constraint "x_user_uk_user_name"
>   Detail: Key (user_name)=(rangerlookup) already exists.
> Error Code: 0
> Call: INSERT INTO x_user (ID, ADDED_BY_ID, CREATE_TIME, CRED_STORE_ID, DESCR, 
> IS_VISIBLE, USER_NAME, OTHER_ATTRIBUTES, STATUS, UPDATE_TIME, UPD_BY_ID) 
> VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
>     bind => [11 parameters bound]
>     at 
> org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:980)
>     at jdk.internal.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
>     at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>     at 
> org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:301)
>     at com.sun.proxy.$Proxy26.flush(Unknown Source)
>     at org.apache.ranger.common.db.BaseDao.create(BaseDao.java:90)
>     at 
> org.apache.ranger.service.AbstractBaseResourceService.createResource(AbstractBaseResourceService.java:258)
>     at 
> org.apache.ranger.biz.XUserMgr.createServiceConfigUser(XUserMgr.java:2535)
>     at 
> org.apache.ranger.biz.XUserMgr$$FastClassBySpringCGLIB$$57c6d473.invoke(<generated>)
>     at 
> org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
>     at 
> org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:737)
>     at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
>     at 
> org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
>     at 
> org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:283)
>     at 
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
>     at 
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
>     at 
> org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:672)
>     at 
> org.apache.ranger.biz.XUserMgr$$EnhancerBySpringCGLIB$$886cf35.createServiceConfigUser(<generated>)
>     at 
> org.apache.ranger.biz.ServiceDBStore.createDefaultPolicyUsersAndGroups(ServiceDBStore.java:3321)
>     at 
> org.apache.ranger.biz.ServiceDBStore.populateDefaultPolicies(ServiceDBStore.java:3236)
>     at 
> org.apache.ranger.biz.ServiceDBStore.createDefaultPolicies(ServiceDBStore.java:3139)
>     at 
> org.apache.ranger.biz.ServiceDBStore.createService(ServiceDBStore.java:1545)
>     at org.apache.ranger.rest.ServiceREST.createService(ServiceREST.java:767) 
> {code}
> Note: Issue is intermittent and difficult to reproduce manually.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to