Error on Discovery enable

Continuous updates has challenged my Tutor instance and I’m facing more errors than usual. When upgrading and launching the discovery service I now get a duplicate entry error:

django.db.utils.IntegrityError: (1062, "Duplicate entry 'discovery.localhost' for key 'django_site_domain_a2e37b91_uniq'")

I would prefer not to delete the database folder and I’m seeking a best-practice type of way of dealing with these. I guess disabling plugins don’t remove their settings / database entries from the platform configuration? Should I manually delete the db entry?

Do you know what was the version of the discovery plugin prior to upgrade? Is this a development or a production instance?

EDIT: do NOT delete the database :slight_smile:

This is a development instance where I test things (like updates, xblocks) before doing the same on the production server. I rsync the production data to the dev server, then run all the updates and tests, before doing the same to the production server.

This was discovery v.0.1.14. I upgraded from 0.1.9, I believe.

Did you set “localhost” as the LMS_HOST value? You can check with tutor config printvalue LMS_HOST.

Yes, it’s set at localhost

You should never use “localhost” as the LMS or Studio host name, even in development. On my machine, I just set it to “myopenedx.com”. Actually, I need to modify Tutor to check the validity of this value.

That seemed to clear that error up, but now ending up with

Found existing user: "discovery"
CommandError: Skipping user "discovery" because the specified and existing email addresses do not  match.

Can you please paste a larger section of that stacktrace? Also, what command are you running?

Here from paste bin: https://pastebin.com/raw/LwCse2sD

Can you try to delete the discovery user from the Django administration panel? Here is the url: /admin/oauth2/client/
Then, attempt to run tutor local init again.

Removing the users “discovery” AND “lms_catalog_service_user” was the solution. I guess I messed up with the localhost setting somehow.

Having upgraded to tutor-discovery 10.0.0 and tutor-openedx 10.0.1, I encounter the error “Found existing user” and that “the email addresses do not match”. I probably used another email address in the setup?

It’s the same problem as above, but the user is no longer located at /admin/oauth2/client/, but at admin/auth/user/.

However, when attempting to delete the user, I get a 500-error with the following log-output:

   lms_1               | django.db.utils.IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`openedx`.`oauth2_accesstoken`, CONSTRAINT `oauth2_accesstoken_user_id_bcf4c395_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`))')

I found a work-around:

Guess the same thing will happen to the e-commerce plugin