fix resource insert race condition