Changes subnet selection to reduce deadlocks

RM10449

Updates the subnet selection logic in IPAM in several places to account
for accidentally locking the subnets table as a side-effect when selecting
  IP addresses.