# Failed to finalize task

**URL:** <https://community.sonarsource.com/t/failed-to-finalize-task/23412>\
**Category:** SonarQube Server / Community Build\
**Tags:** background\_task\
**Created:** [April 21, 2020, 10:11am UTC](https://community.sonarsource.com/t/failed-to-finalize-task/23412 "2020-04-21T10:11:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Ghanmi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ahmed_ghanmi/32/4011_2.png) [@Ahmed\_Ghanmi](https://community.sonarsource.com/u/Ahmed_Ghanmi)\
**Post date:** [April 21, 2020, 10:11am UTC](https://community.sonarsource.com/t/failed-to-finalize-task/23412/1 "2020-04-21T10:11:22Z")

</div>

I have the same error this is the compute engine logs

```auto
2020.04.21 10:28:05 ERROR ce[AXGb2TumVm04a7-8faQz][o.s.c.t.CeWorkerImpl] Failed to finalize task with uuid 'AXGb2TumVm04a7-8faQz' and persist its state to db
java.lang.IllegalStateException: Task does not exist anymore: CeTask{organizationUuid=AWkv_fdNs5cDpYntB8Oq, type=REPORT, uuid=AXGb2TumVm04a7-8faQz, component=Component{uuid='AW3-Ao6U3lZs7YVNM03x', key=' *******', name='******'}, mainComponent=Component{uuid='AW3-Ao6U3lZs7YVNM03x', key=' ********', name='******'}, submitter=User{uuid=' ******', login='********'}}
	at org.sonar.ce.queue.InternalCeQueueImpl.lambda$remove$0(InternalCeQueueImpl.java:118)
	at java.base/java.util.Optional.orElseThrow(Optional.java:408)
	at org.sonar.ce.queue.InternalCeQueueImpl.remove(InternalCeQueueImpl.java:118)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.finalizeTask(CeWorkerImpl.java:242)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.afterExecute(CeWorkerImpl.java:236)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.close(CeWorkerImpl.java:196)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:159)
	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)

```

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [April 21, 2020, 4:46pm UTC](https://community.sonarsource.com/t/failed-to-finalize-task/23412/2 "2020-04-21T16:46:14Z")

</div>

Hi,

You haven’t given us much here. How about some context?

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![Tarig0](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tarig0/32/8341_2.png) [@Tarig0](https://community.sonarsource.com/u/Tarig0)\
**Post date:** [June 10, 2020, 5:27pm UTC](https://community.sonarsource.com/t/failed-to-finalize-task/23412/3 "2020-06-10T17:27:38Z")

</div>

I may be able to give some context to a similar message I have in my logs.

> 2020.06.10 13:05:10 TRACE ce[sql] time=0ms | sql=select cq.uuid, cq.task\_type as taskType, cq.component\_uuid as componentUuid, cq.main\_component\_uuid as mainComponentUuid, cq.status as status, cq.submitter\_uuid as submitterUuid, cq.worker\_uuid as workerUuid, cq.started\_at as startedAt, cq.created\_at as createdAt, cq.updated\_at as updatedAt from ce\_queue cq where cq.status = ‘PENDING’ and cq.started\_at is not null  
> \*\*  
> 2020.06.10 13:06:13 ERROR ce[AXKfMQ7tAPMkJXsnYaNK][o.s.c.t.CeWorkerImpl] Failed to finalize task with uuid ‘AXKfMQ7tAPMkJXsnYaNK’ and persist its state to db  
> IllegalStateException stacktrace  
> 2020.06.10 13:06:13 INFO ce[AXKfMQ7tAPMkJXsnYaNK][o.s.c.t.CeWorkerImpl] Executed task | project=\*\*\* | type=REPORT | branch=\*\*\* | branchType=BRANCH | id=AXKfMQ7tAPMkJXsnYaNK | submitter=\*\*\* | status=SUCCESS | time=80568ms

This happens on a 8.3.1.34397 install that started with a blank MSSQL server.

I am not sure where to go after this other than to move the SQL server to a different product/location

---

<div class="post-metadata">

**Author:** ![Tarig0](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tarig0/32/8341_2.png) [@Tarig0](https://community.sonarsource.com/u/Tarig0)\
**Post date:** [June 10, 2020, 5:40pm UTC](https://community.sonarsource.com/t/failed-to-finalize-task/23412/4 "2020-06-10T17:40:19Z")

</div>

Also the measures tab for any scans that “partially” complete will display “The request cannot be processed. Try again later.” when trying to activate the measure tab.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [June 10, 2020, 6:36pm UTC](https://community.sonarsource.com/t/failed-to-finalize-task/23412/5 "2020-06-10T18:36:35Z")

</div>

@Tarig0, is there anything else in your logs?

Regarding the UI, what do you see in your browser console? I guess a 500 error? If so, that would be worth checking `web.log` for.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![Tarig0](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tarig0/32/8341_2.png) [@Tarig0](https://community.sonarsource.com/u/Tarig0)\
**Post date:** [June 10, 2020, 6:41pm UTC](https://community.sonarsource.com/t/failed-to-finalize-task/23412/6 "2020-06-10T18:41:39Z")

</div>

I think I was getting the “request cannot be processed” message was because even though the status is canceled for the background task its still running the CE so the metrics were still being processed… After a few more minutes I was able to pull the metrics.

I would like to concentrate on why the CE background tasks are being lost in the queue while being processed though. I’m not seeing them being deleted anywhere in the CE log.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [June 10, 2020, 7:09pm UTC](https://community.sonarsource.com/t/failed-to-finalize-task/23412/7 "2020-06-10T19:09:38Z")

</div>

In the related thread that this one was split from, it was a problem with too little filespace available to the DB. We’ve also seen a problem when the CI deletes the branch in SonarQube _while_ an analysis is being processed for it. Does either of these sound right?

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![Tarig0](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tarig0/32/8341_2.png) [@Tarig0](https://community.sonarsource.com/u/Tarig0)\
**Post date:** [June 11, 2020, 1:19pm UTC](https://community.sonarsource.com/t/failed-to-finalize-task/23412/8 "2020-06-11T13:19:14Z")

</div>

Branch is a long living branch so that doesn’t make sense. No indicators of memory issues on the mssql server.

---

<div class="post-metadata">

**Author:** ![Tarig0](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tarig0/32/8341_2.png) [@Tarig0](https://community.sonarsource.com/u/Tarig0)\
**Post date:** [July 21, 2020, 5:22pm UTC](https://community.sonarsource.com/t/failed-to-finalize-task/23412/9 "2020-07-21T17:22:46Z")

</div>

@Ahmed_Ghanmi I found out my issue was multiple sonarqube front end servers using the same sql server. You can check this by changing your connection string to use a new database catalog/instance and see if that resolves the error.
