The ResourceManager can fail while sorting queues if an update comes in:
The reason it breaks is a change in the sorted object itself.
This is why it fails:
- an update from a node comes in as a heartbeat.
- the update triggers a check to see if we can assign a container on the node.
- walk over the queue hierarchy to find a queue to assign a container to: top down.
- for each parent queue we sort the child queues in assignContainer to decide which queue to descent into.
- we lock the parent queue when sort to prevent changes, but we do not lock the child queues that we are sorting.
If during this sorting a different node update changes a child queue then we allow that. This means that the objects that we are trying to sort now might be out of order. That causes the issue with the comparator. The comparator itself is not broken.