Restore fails with "hotlinked_media_status" already exists

Continuing the discussion from Upgrade fails on duplicate key error ("index post hotlinked media on post id and url md5"):

I’m now trying to restore from one prod site to a staging site and I’m getting:

ERROR:  type "hotlinked_media_status" already exists
EXCEPTION: psql failed: ERROR:  type "hotlinked_media_status" already exists

@david is there some case you somehow missed when you fixed this before (I think it was failing on migrations then, and this is a restore).

1 Like

How are you restoring the site? Via the UI? discourse CLI? direct psql?

From the command line restoring the most recent backup (I figured out this sed trick today, but it was the same if I copy/pasted).

$(discourse restore |sed -n '3p')

And the backup is on S3 restored from a slightly older version:

Discourse 3.4.0.beta1-dev - https://github.com/discourse/discourse version a3d61ba1c43931eb688f9b2b85c207b5bab02b8c

to

Discourse 3.4.0.beta2-dev - https://github.com/discourse/discourse version f405c021ebd36d5f11499159bd2b54098356a8f9"

Are you able to reproduce the issue on any other installation?

It’s quite surprising that this issue is cropping up more than 2 years later, and without any other reports :thinking:

Maybe not? I did successfully restore that same backup on my dev box.

Do you have any idea what I might have done to cause this or what I can do to fix it? I dropped the database and than was able to restore. Dropping the database was the actual solution, but I don’t deserve a solution for a problem I (seem to have) caused.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

One very valuable insight that I just had is that hotlinked_media_status is simply the first thing happening in the restore file. If you remove it manually in the existing database the restore will fail on the next statement (CREATE TABLE public.admin_notices).

So this is not about that specific type definition. It’s just a symptom of a bigger problem, I suspect that BackupRestore.move_tables_between_schemas(MAIN_SCHEMA, BACKUP_SCHEMA) fails to do what it’s gotta do.

1 Like