How to debug or fix Visit of Component {key=XXX,uuid=XXX,type=xxx} failed

Version info

soanrqube version CE 7.9.2
postgresql version CE 10.11

environment introduce

I have a postgresql cluster with 3 nodes and a pgpool-II cluster with 3 nodes in master-slave mode.They are installed on the same servers.I updated my sonarqube from 6.7.9 to 7.9.2 ,it occurred some problems when i migrated data from mysql to postgresql ,but i fixed it.And now,when i try to scan my projects,it some times failed with error message below . I don’t know how to debug it or fix it ,it seems something wrong with SnapshotMapper.I’m sure that i have only one sonarqube instance at the same time.Although i try to use keepalived to achieve high ability.but it just mean the sonarqube server has a vip.

error log information

org.sonar.ce.task.projectanalysis.component.VisitException: Visit of Component {key=NRCS_nrcs-busi-cps_feature_58646,uuid=AWzxB8c2yZooBLmDKKro,type=PROJECT} failed
at org.sonar.ce.task.projectanalysis.component.VisitException.rethrowOrWrap(VisitException.java:44)
at org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:41)
at org.sonar.ce.task.projectanalysis.step.PersistAnalysisStep.execute(PersistAnalysisStep.java:63)
at org.sonar.ce.task.step.ComputationStepExecutor.executeStep(ComputationStepExecutor.java:81)
at org.sonar.ce.task.step.ComputationStepExecutor.executeSteps(ComputationStepExecutor.java:72)
at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:59)
at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:81)
at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:209)
at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:191)
at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:158)
at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:133)
at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:85)
at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.ibatis.exceptions.PersistenceException:

I have solved this problem.Please do not reply

Hi @icelollipop,

How did you solve the issue? I am facing the same or similiar issue and would appreciate your help.

Hi,Daniel Schiffer.Indead,there are still some more log information.I will show you first and then tell you how did i resolve it.I hope it will help you.

Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "pk_snapshots"
Detail: Key (id)=(32664) already exists.
The error may exist in org.sonar.db.component.SnapshotMapper
The error may involve org.sonar.db.component.SnapshotMapper.insert-Inline
The error occurred while setting parameters
SQL: insert into snapshots (       uuid,       component_uuid,       created_at,       build_date,       status,       islast,       version,       build_string,       period1_mode,       period1_param,       period1_date,       revision     )     values (       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?     )
Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "pk_snapshots"
Detail: Key (id)=(32664) already exists.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:199)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)

I check the table snapshots in database sonar.And I find the max ‘id’ is not equal to the number remembered by pgsql.So ,I change the max ‘id’ remembered by pgsql.And the problem was solved.
you can use
select nextval('snapshots_id_seq')
to query the next id base on current max id.And then ,you can set a appropriate value of it.

Hi,

It is not the issue I face. Nevertheless, thank you for sharing your solution.