New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Npgsql.PostgresException (0x80004005): XX000: cache lookup failed for type #2366
Comments
The latter part of the issue talks about reloading types, so I'm not exactly sure whether you're using custom types or not. If you're really not using custom types, then
Dropping a custom type and recreating it is a pretty drastic operation, and (at least up to now) there's been no expectation for the driver to handle such an event transparently. As a general rule, we try not to contain automatic, under-the-hood recovery - as a general rule this tends to be brittle and bloat the driver with complicated behavior. May I ask in what scenario you're dropping and recreating your custom type, and why you can't simply call
That's actually a pretty good answer to why Npgsql doesn't contain automatic logic for internally calling |
There wasn't any Maybe
The application didn't have any changes, it was a website not an app and it was an update to the tables in that schema where the data was transformed and additional columns added/removed/ int to bigint etc. The website did not need to know about the change. The issue happens even if there are no table/column changes. The steps to reproduce the steps easily by creating a connection and do a select off a table in a schema (let it finish) and then while the connection is still open drop the schema and then recreate the schema with the table and while using the open connection do the same select off of it. |
Yes, types coming from extensions like Please confirm that the issue is indeed related to One last suggestion - |
I have the same issue with postgis. In our MSTest project we have the following
but seeding fails with the cache lookup errors, even trying to manually call Our initial migrations contains
My solution for the time being is
|
@ryan-morris that makes sense. The Npgsql EF Core provider automatically calls In actual production use, it is usually recommended to generate migration SQL scripts and apply them externally, rather than programmatically (in this case there's no issue). For testing what you're doing should be fine, but it's still up to you to manually reload types. Am closing this issue as an answer has been provided, and no confirmation has been received in the last month. |
Steps to reproduce
https://stackoverflow.com/questions/51086421/npgsql-postgresexception-0x80004005-xx000-cache-lookup-failed-for-type-20785
Similar issue as above, except no custom types being used. Basically all you need to do is
DROP SCHEMA myschema;
and thenCREATE SCHEMA myschema;
and also create the tables while the website is already running and have already made some executions on that schema.What happened to us was...
While the website was running, a db update was sent out that dropped a schema (data was moved first) and then recreated the schema with all the tables and their changes and data was re-inserted into the newly recreated schema. Afterwards going to the website threw this error
Npgsql.PostgresException (0x80004005): XX000: cache lookup failed for type
and kept throwing that error and took down the website until someone restarted the website.The issue
Why is Npgsql throwing that error instead of just reloading the types automatically and then retrying again?
NpgsqlConnection.ReloadTypes()
If anything it should at least attempt to reload the types at least once.Also the exception is a generic
Npgsql.PostgresException
and one would need to examine the error message text to determine that the types needed to be reloaded.This seems something low level that Npgsql should handle out of the box (by automatically
ReloadTypes()
instead of forcing Npgsql users in implementing a global catch all for an error message text value that hascache lookup failed for type
in it as Npgsql could change that error message text in the future.Further technical details
Npgsql version: 4.0.3
PostgreSQL version: 11
Operating system: Windows
The text was updated successfully, but these errors were encountered: