Last Updated: February 25, 2016
·
2.129K
· glauco

Solving TFS 2010 Build Stuck as Infinitely Queued

Recently I've noticed that my build agent stopped working for no reason.
Also, I noticed that I was unable to delete the build agent with the following error message:
"Cannot remove build agent [my build agent] from build controller because it is currently reserved for a build".

I tried to delete every single item from the build queue, but it didn't worked.

Finally I figured out that the only way to solve that problem was by deleting the build entries directly on TFS database.

I connected to my team project collection db (tfs_[collection name]), and then executed the following SQL statement:

SELECT * FROM tbl_BuildAgent

I found the build agent that wasn't working properly.

I executed the following SQL statements:

DELETE tbl_BuildAgentReservation 
WHERE ReservationId = [ReservationId]

DELETE tbl_BuildQueue 
WHERE ControllerId = [ControllerId]

UPDATE tbl_BuildAgent 
SET ReservationId = NULL 
WHERE AgentId = [AgentId]

That's it. Now it's working properly.