Fix race condition in dynamic pool creation