[Solved] Background tasks cancelled randomly

Hello,

We are launching analysis from Cloudbees pipeline but sometimes the analysis is cancelled with no reason. This beaviour occurs since we update Sonarqube from 7.9.1 to 8.3.1. We also update our Sonar Scanner to version 4.3.

Log show no messages even with trace level.

In background task, we can see the analysis is pending whereas no other activity is in progress. And after about 1min, the task is cancelled.

I already check the PostgreSQL database, server load and the sonar webhook configuration but all seems fine.

Here is the pipeline use to launch analysis :

stage('quality') {
            tools {
                jdk "JDK openjdk 11"
            }
                steps {
                    script {
                        // add GIT_BRANCH to sonar analysis
                        def sonarBranch = ''
                        if ( GIT_BRANCH.trim().contains('origin/master')) {
                            sonarBranch = "master"
                        } else {
                            sonarBranch = GIT_BRANCH.replace("origin/","")
                        }
                        def scannerHome = tool 'Sonar Scanner 4.3'
                        utilsExecuteCommand(cmd: "mvn clean verify -Pcoverage")
                        withSonarQubeEnv('Sonar LTS') {
                            if (isUnix()) {
                                utilsExecuteCommand(cmd: "${scannerHome}/bin/sonar-scanner -D${sonarBranch}")
                            } else 
                                utilsExecuteCommand(cmd: "${scannerHome}/bin/sonar-scanner.bat -D${sonarBranch}")
                        }
                    }
                updateGitlabCommitStatus name: 'quality', state: 'success'
            }
        }
        
        stage('quality gate') {
            tools {
                jdk "JDK openjdk 11"
            }
            steps {
                script {
                    timeout(time: 10) {
                        def qualitygate = waitForQualityGate()
                        if (qualitygate.status != "OK") {
                            error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
                        }
                    }
                }
            }
        }

Any idea of what goes wrong ?

Thanks.

HI @rloic,

It looks like this is your first post, so welcome to the community! :smiley:

Random cancellation of background tasks is often a symptom of having multiple SonarQube instances connected to the same database. Can you check whether you accidentally have two SonarQube instances pointing to the same database? You can also look in the ce.log file on your instance, you should see error messages like this:

Failed to finalize task with uuid 'BT5IxF_fyNK-3XhbZ5rY' and persist its state to db
java.lang.IllegalStateException: Task does not exist anymore: 

If there aren’t two instances connected to the same database, are you seeing any other errors in the ce.log file?

Regards,

Cameron.

2 Likes

Hi @Cameron

:muscle:

Indeed, an old installation of Sonarqube (7.6) was running on another server. I find it thanks the database connection list and especially your help.

Thanks a lot.

1 Like

Hello @rloic,

Glad to see that you manage to find a solution. :slight_smile:

Just a quick note to say that you can also mark an answer as “solution” instead of editing the title.

Best,
Quentin

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.