Instead of getting the highest partition id + 1 as next partition, get the partition id from 0..max_existing+1 that isn't used.  So if you have partition ids [2,3], return 1.
Instead of getting the highest partition id + 1 as next partition, get the partition id from 0..max_existing+1 that isn't used.  So if you have partition ids [2,3], return 1.

Quyzi/gpt