Adding a mutex to insertplan to avoid race condition