The end_job function was calling Lwt.pause between the selection of the node and its update which was making capacity of the node to decrease.