Why was the task been cancel?

Hello!
After I changed the server for sonarqube last weekend, I found that background tasks were often cancelled. How do I need to fix it. The database instance has not been replaced.

  • which versions are you using
    SonarQube 9.4.0.54424

  • what are you trying to achieve
    Background tasks should not be cancelled unexpectedly

  • what have you tried so far to achieve this
    This affects the CI process

The following is the log of one of the tasks in ce.log

2022.08.24 10:10:29 INFO  ce[][o.s.c.t.CeWorkerImpl] Execute task | project=srp | type=REPORT | pullRequest=211000 | id=AYLNnYH0yf0HFOeeqNUA | submitter=admin
2022.08.24 10:10:30 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Extract report | status=SUCCESS | time=150ms
2022.08.24 10:10:30 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist scanner context | status=SUCCESS | time=27ms
2022.08.24 10:10:30 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Propagate analysis warnings from scanner report | status=SUCCESS | time=0ms
2022.08.24 10:10:30 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Generate analysis UUID | status=SUCCESS | time=0ms
2022.08.24 10:10:30 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Load analysis metadata | status=SUCCESS | time=17ms
2022.08.24 10:10:30 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Initialize | status=SUCCESS | time=13ms
2022.08.24 10:10:30 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Build tree of components | components=9 | status=SUCCESS | time=14ms
2022.08.24 10:10:30 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Validate project | status=SUCCESS | time=7ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Load quality profiles | status=SUCCESS | time=1016ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Load Quality gate | status=SUCCESS | time=49ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Load new code period | status=SUCCESS | time=0ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Detect file moves | status=SUCCESS | time=0ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Load duplications | duplications=66 | status=SUCCESS | time=6ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute cross project duplications | status=SUCCESS | time=0ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute size measures | status=SUCCESS | time=1ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute new coverage | status=SUCCESS | time=6ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute coverage measures | status=SUCCESS | time=95ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute comment measures | status=SUCCESS | time=0ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute duplication measures | status=SUCCESS | time=0ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute size measures on new code | status=SUCCESS | time=0ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute language distribution | status=SUCCESS | time=0ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute test measures | status=SUCCESS | time=0ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute complexity measures | status=SUCCESS | time=0ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Load measure computers | status=SUCCESS | time=0ms
2022.08.24 10:10:31 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute Quality Profile status | status=SUCCESS | time=4ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Execute component visitors | status=SUCCESS | time=149672ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Checks executed after computation of measures | status=SUCCESS | time=62ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute Quality Gate measures | status=SUCCESS | time=1ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Compute Quality profile measures | status=SUCCESS | time=0ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Generate Quality profile events | status=SUCCESS | time=14ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Generate Quality gate events | status=SUCCESS | time=0ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Check upgrade possibility for not analyzed code files. | status=SUCCESS | time=0ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist scanner analysis cache | status=SUCCESS | time=0ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist components | status=SUCCESS | time=172ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist analysis | status=SUCCESS | time=10ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist analysis properties | status=SUCCESS | time=37ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist measures | inserts=52 | status=SUCCESS | time=42ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist live measures | insertsOrUpdates=490 | status=SUCCESS | time=248ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist duplication data | insertsOrUpdates=0 | status=SUCCESS | time=6ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist new ad hoc Rules | status=SUCCESS | time=0ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist issues | cacheSize=7.7 kB | inserts=14 | updates=0 | merged=0 | status=SUCCESS | time=192ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist project links | status=SUCCESS | time=0ms
2022.08.24 10:13:01 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist events | status=SUCCESS | time=6ms
2022.08.24 10:13:02 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist sources | status=SUCCESS | time=289ms
2022.08.24 10:13:02 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Persist cross project duplications | status=SUCCESS | time=0ms
2022.08.24 10:13:02 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Enable analysis | status=SUCCESS | time=7ms
2022.08.24 10:13:02 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Update last usage date of quality profiles | status=SUCCESS | time=5ms
2022.08.24 10:13:02 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Purge db | status=SUCCESS | time=66ms
2022.08.24 10:13:02 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Index analysis | status=SUCCESS | time=49ms
2022.08.24 10:13:02 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Update need issue sync for branch | status=SUCCESS | time=4ms
2022.08.24 10:13:02 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Send issue notifications | status=SUCCESS | time=0ms
2022.08.24 10:13:02 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Publish task results | status=SUCCESS | time=0ms
2022.08.24 10:13:02 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.s.ComputationStepExecutor] Trigger refresh of Portfolios and Applications | status=SUCCESS | time=0ms
2022.08.24 10:13:03 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Webhooks | globalWebhooks=1 | projectWebhooks=0 | status=SUCCESS | time=1456ms
2022.08.24 10:13:03 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Pull Request decoration | status=SUCCESS | time=11ms
2022.08.24 10:13:03 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Report branch Quality Gate status to devops platforms | status=SUCCESS | time=0ms
2022.08.24 10:13:03 ERROR ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.CeWorkerImpl] Failed to finalize task with uuid 'AYLNnYH0yf0HFOeeqNUA' and persist its state to db
java.lang.IllegalStateException: Task does not exist anymore: CeTask{type=REPORT, uuid=AYLNnYH0yf0HFOeeqNUA, component=Component{uuid='AYLNnYHoyf0HFOeeqNT_', key='srp:PULL_REQUEST:211000', name='srp'}, mainComponent=Component{uuid='AYBrr-X-ZObeRRz8CtEz', key='srp', name='srp'}, submitter=User{uuid='AYBKsaNC-ne8H-Wu9gBY', login='admin'}}
	at org.sonar.ce.queue.InternalCeQueueImpl.lambda$remove$0(InternalCeQueueImpl.java:123)
	at java.base/java.util.Optional.orElseThrow(Optional.java:408)
	at org.sonar.ce.queue.InternalCeQueueImpl.remove(InternalCeQueueImpl.java:123)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.finalizeTask(CeWorkerImpl.java:245)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.afterExecute(CeWorkerImpl.java:239)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.close(CeWorkerImpl.java:199)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:161)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:135)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:87)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
	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)
2022.08.24 10:13:03 INFO  ce[AYLNnYH0yf0HFOeeqNUA][o.s.c.t.CeWorkerImpl] Executed task | project=srp | type=REPORT | pullRequest=211000 | id=AYLNnYH0yf0HFOeeqNUA | submitter=admin | status=SUCCESS | time=153859ms

Most often, a canceled background task is the result of multiple SonarQube instances being connected to the same database. Can you check to make sure this isn’t the case (even by accident)?

I’m pretty sure I started only one instance of sonar. I checked the sonar instance of the old server. It is in shutdown state

I would recommend checking the connections being made to your database so see if there’s a rogue connection you don’t expect. For example, here’s how to do so for SQL Server.

I excute “select distinct client_addr from pg_stat_activity ;” in my db,and there is the result
image
10.110.71.27 is the new sonar server.The remaining three IP addresses are all used to perform some query services.

Hello!
I’m very sure that no second sonar instance is connected to the database. Do you have any other repair suggestions?

There is my license info

and system info