Issue with the project key


(Tulasi Perigisetti) #1

Hello Team,

I am using sonarqube 6.7.5 LTS.

One of the users is trying to run analysis for the first time with “mvn sonar:sonar -Dsonar.analysis.mode=publish” and gets the message “Failed to upload report - 500: An error has occurred”.

I checked server side logs - web.log and found the below error.

2019.02.18 06:05:21 ERROR web[AWjw9hvIZvKdha2TBiKc][o.s.s.w.WebServiceEngine] Fail to process request 
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "uniq_group_roles"
  Detail: Key (organization_uuid, group_id, resource_id, role)=(AWVOZXBjiGkI7Zc8DBxe, 1, 2603984, user) already exists.
### The error may involve org.sonar.db.permission.GroupPermissionMapper.insert-Inline
### The error occurred while setting parameters
### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "uniq_group_roles"

Request you to help me to resolve this issue.

Best Regards
Tulasi Perigisetti


(Tulasi Perigisetti) #2

Can someone help me on this issue.


(Julien Lancelot) #4

Hi,

It seems that the permission ‘Browse’ already exists for this project, or at least for the project ID 2603984 that will be used for this project.
Have you manually update the database in the past ?
Have you tried many times ?

Regards,
Julien Lancelot


(Tulasi Perigisetti) #5

Hi Julien,

Thanks for your response.
Browse permission exists on the project on which the analysis is run, but couldn’t find Project ID 2603984 in the database.
I haven’t tried to update the database manually.

Best Regards
Tulasi Perigisetti


(Julien Lancelot) #6

Could you please share the whole stacktrace ?


(Tulasi Perigisetti) #7

Running the project with “mvn sonar:sonar -Dsonar.analysis.mode=publish” gives an error message “Failed to upload report - 500: An error has occurred”.

Checked web logs for the project and found below stacktrace.

**2019.02.18 06:05:21 ERROR web[AWjw9hvIZvKdha2TBiKc][o.s.s.w.WebServiceEngine] Faa
il to process request http://sonarqube.xx.xx.xx/api/ce/submit?projectKey=com.xx.commonlibrary:virtual-machine-manager&projectName=virtual-machine-manager
org.apache.ibatis.exceptions.PersistenceException:

Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “uniq_group_roles”

Detail: Key (organization_uuid, group_id, resource_id, role)=(AWVOZXBjiGkI7Zc8DBxe, 1, 2603984, user) already exists.

The error may involve org.sonar.db.permission.GroupPermissionMapper.insert-Inline

The error occurred while setting parameters

Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “uniq_group_roles”

The error may involve org.sonar.db.permission.GroupPermissionMapper.insert-Inline

The error occurred while setting parameters

Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “uniq_group_roles”

Detail: Key (organization_uuid, group_id, resource_id, role)=(AWVOZXBjiGkI7Zc8DBxe, 1, 2603984, user) already exists.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:57)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy78.insert(Unknown Source)
at org.sonar.db.permission.GroupPermissionDao.insert(GroupPermissionDao.java:119)
at org.sonar.server.permission.PermissionTemplateService.lambda$copyPermissions$4(PermissionTemplateService.java:152)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at org.sonar.server.permission.PermissionTemplateService.copyPermissionss(PermissionTemplateService.java:146)
at org.sonar.server.permission.PermissionTemplateService.applyDefault(PermissionTemplateService.java:114)
at org.sonar.server.component.ComponentUpdater.handlePermissionTemplate(ComponentUpdater.java:143)at org.sonar.server.component.ComponentUpdater.create(ComponentUpdater.java:80)
at org.sonar.server.computation.queue.ReportSubmitter.createProject(ReportSubmitter.java:169)
at org.sonar.server.computation.queue.ReportSubmitter.lambda$submit$0(ReportSubmitter.java:95)
at com.google.common.base.Absent.or(Absent.java:60)
at org.sonar.server.computation.queue.ReportSubmitter.submit(ReportSubmitter.java:95)
at org.sonar.server.ce.ws.SubmitAction.handle(SubmitAction.java:114)
at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:103)
at org.sonar.server.ws.WebServiceFilter.doFilter(WebServiceFilter.java:86)
at org.sonar.server.platform.web.MasterServletFilter$GodFilterChain.doFilter(MasterServletFilter.java:126)
at org.sonar.server.platform.web.MasterServletFilter.doFilter(MasterServletFilter.java:95)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:87)
at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:71)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sonar.server.platform.web.SecurityServletFilter.doHttpFilter(SecurityServletFilter.java:72)
at org.sonar.server.platform.web.SecurityServletFilter.doFilter(SecurityServletFilter.java:48)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sonar.server.platform.web.RedirectFilter.doFilter(RedirectFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sonar.server.platform.web.requestid.RequestIdFilter.doFilter(RequestIdFilter.java:63)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sonar.server.platform.web.RootFilter.doFilter(RootFilter.java:62)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:256)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint “uniq_group_roles”
Detail: Key (organization_uuid, group_id, resource_id, role)=(AWVOZXBjiGkI7Zc8DBxe, 1, 2603984, user) already exists.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2422)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2167)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)
at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:144)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
at org.apache.ibatis.executor.ReuseExecutor.doUpdate(ReuseExecutor.java:52)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
… 67 common frames omitted**


(Julien Lancelot) #8

This error is showing that this is the first analysis of this project.

Could you try to create the project first in the UI or by WS ?


(Tulasi Perigisetti) #9

Hi,

Project can be created in the UI.

The issue is while creating project from the first analysis. We need projects to be created directly from the analysis

Best Regards
Tulasi Perigisetti


(Julien Lancelot) #10

To clarify, when you create the project from the UI and then execute the analysis, everything is working well ?


(Tulasi Perigisetti) #11

Yes Julien, executing the analysis after creating the project in the UI is successful.

Trying to create project after changing the key from “com.xx.commonlibrary:virtual-machine-manager” to anything like “com.xx.test:virtual-machine-manager” is also working.

But we need the project to be created with the same key.


(Tulasi Perigisetti) #12

Hi Team,

Request you to help me with this issue as we are struck here.

I need to create projects directly by running analysis.

Best Regards
Tulasi Perigisetti


(Tulasi Perigisetti) #13

Hi Team,

From the error, we figured out that two rows with the same key are being inserted into the table in database, and its resulting in violation of key.
Can someone please help us with how to resolve this issue.

Best Regards
Tulasi Perigisetti


(Julien Lancelot) #14

I’m sorry, but I’m not sure to be able to help… I have a last idea : could you go to Administration > Projects > Management and search for the project you’re trying to analyze ?
And if it’s there, then delete it.