Thread-safe insert for MongoDB