add lock in entity_manager