Multiple analysis on same branch: IllegalStateException: Task does not exist anymore:

Must-share information (formatted with Markdown):
*** which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)**
7.6 Sonarqube Server Developer Edition
sonaraube gradle plugin

*** what are you trying to achieve**
We currently have a jenkins which triggers a build whenever we’re pushing a commit on the main branch.
The last part of this build is to run an analysis on the main branch and then check the quality gates. The problem is that sometimes the build is running indefinitely when it reaches this step. Checking the sonarqube logs i came across this:

2019.04.10 11:00:01 INFO  ce[AWoG5fHZdEbihMYTJkOO][o.s.c.t.s.ComputationStepExecutor] Trigger 
refresh of Portfolios and Applications | status=SUCCESS | time=0ms
2019.04.10 11:00:02 ERROR ce[AWoG5fHZdEbihMYTJkOO][o.s.c.t.CeWorkerImpl] Failed to finalize              
task with uuid 'AWoG5fHZdEbihMYTJkOO' and persist its state to db
java.lang.IllegalStateException: Task does not exist anymore:
CeTask{organizationUuid=AWKWo6A5ulOKIs2nq0kp, type=REPORT, 
uuid=AWoG5fHZdEbihMYTJkOO, component=Component{uuid='AWaN1ScSmjiUrmbx_wLv', 
key='Project', name='Project'}, mainComponent=Component{uuid='AWaN1ScSmjiUrmbx_wLv', 
key='Project', name='Project'}, submitter=User{uuid='jenkins', login='jenkins'}}
2019.04.10 11:00:02 INFO  ce[AWoG5fHZdEbihMYTJkOO][o.s.c.t.CeWorkerImpl] Executed task | 
project=Project | type=REPORT | branch=develop | branchType=LONG | 
| submitter=jenkins | status=SUCCESS | time=107296ms

But we’re not sure if it’s related to the problem or not. I haven’t found anything about how a task reaches the cancel state.
Could it be because the builds that are running are too close to one another?


At a guess, your Jenkins job is set to wait a little while and then poll SonarQube for background task completion and then look up the QG status? If I’ve guessed correctly, then you need to upgrade to using Webhooks. It’s easy to do in a pipeline.


Thank you for the reply.
I think there was another issue. We also have a sonar set up for testing and even thought this was not meant, it was connected to the same database and i think that the testing sonar was somehow screw everything up for the prod sonar. But still, what could you tell me about the “canceled” tasks?


All I know about cancelled tasks in Jenkins is that someone clicked the red ‘x’ before the job finished.

Regarding having two SonarQube instances pointed at the same database, this is indeed a recipe for trouble. Once you get that sorted out, maybe things will stabilize.