fix resource insert race condition
Merge pull request #15 from badfortrains/insert_fix

fix resource insert race condition