Skip to content
Advertisement

How to fix cache lookup failure/corrupted database?

I’ve got a postgres database that I’m trying to clean up with drop schema public cascade. The data on it is not that important and I never made any backups. I’m just trying to rebuild it. However, it seems an error I made earlier is causing the drop command to fail. When I run drop schema public cascade, I get a ERROR: cache lookup failed for constraint XXXXX. I checked pg_constraints and it doesn’t exist. It’s probably linked to a table/index that doesn’t exist anymore. Is there anyway I can get rid of this persisting/non-existing constraint so I can cleanup the database?

Advertisement

Answer

Perhaps it is enough to remove the dependency:

DELETE FROM pg_depend
WHERE objid = XXXXX;
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement