XX000: cache lookup failed for type 0 at Npgsql.NpgsqlConnector
See original GitHub issueSteps to reproduce
We run a stored procedure
CREATE OR REPLACE FUNCTION refresh_table(p_SearchTableName text, p_TableName text, p_IdType int) RETURNS BOOLEAN AS $$
DECLARE
drop_statement text;
create_statement text;
reporting_table text;
BEGIN
-- remove special characters
reporting_table := regexp_replace(lower(p_TableName), '[^a-z]+', '', 'g');
drop_statement := 'DROP TABLE IF EXISTS ' || reporting_table || ' cascade';
create_statement := 'CREATE UNLOGGED TABLE '|| reporting_table || ' (ID serial PRIMARY KEY, '
--... columns ...
')' ;
EXECUTE drop_statement;
EXECUTE create_statement;
RETURN TRUE;
END;
$$ LANGUAGE 'plpgsql'
SECURITY DEFINER;
then using the same connection we call conn.ReloadTypes();
after that we open a new connection just to be sure and also call conn.ReloadTypes() in case its part of a connection pool and the connection has types cached.
using (var conn = new NpgsqlConnection(connectionString)) {
conn.Open();
//https://stackoverflow.com/questions/51086421/npgsql-postgresexception-0x80004005-xx000-cache-lookup-failed-for-type-20785
conn.ReloadTypes();
using (var cmd = new NpgsqlCommand(insertSQL, conn)) {
// insert stuff..
...
cmd.ExecuteNonQuery();
// exception thrown here
The issue
Exception thrown: XX000: cache lookup failed for type 0
If you are seeing an exception, include the full exceptions details (message and stack trace).
Exception message:
Stack trace:
XX000: cache lookup failed for type 0 at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext() --- End of stack trace from previous location where exception was thrown ---
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming)
at Npgsql.NpgsqlDataReader.NextResult() at Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken) at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteNonQuery()
at ReportPublisher.PublishEntityTypeAsync[TEntityType,TEntity](String typeName, String type, TEntityType entityType, MiddlewareClient cl, IList`1 entityMeta, CancellationToken cancellationToken)
or
Npgsql.PostgresException : XX000: cache lookup failed for type 0at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<DoReadMessage>g__ReadMessageLong|0(??)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Npgsql.NpgsqlDataReader.NextResult(??)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Npgsql.NpgsqlDataReader.NextResult()
at async Npgsql.NpgsqlCommand.ExecuteReaderAsync(??)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Npgsql.NpgsqlCommand.ExecuteNonQuery(??)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Npgsql.NpgsqlCommand.ExecuteNonQuery()
at async ReportPublisher.PublishEntityTypeAsync[TEntityType,TEntity](String typeName,String type,TEntityType entityType,MiddlewareClient cl,IList`1 entityMeta,CancellationToken cancellationToken)
### Further technical details
Npgsql version: 5.0.3
PostgreSQL version: PostgreSQL 10.11, compiled by Visual C++ build 1800, 64-bit
Operating system: Windows Server 2019 (azure)
Other details about my project setup:
The code is running in an azure function, so there would be connection pooling.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
XX000: cache lookup failed for type 207852 when schema ...
1 Answer. Npgsql caches all the PostgreSQL types in a given database when it first connects to it (the types are cached on...
Read more >Npgsql.PostgresException: XX000: cache lookup failed
Npgsql.PostgresException (0x80004005): XX000: cache lookup failed for type 207852 when schema dropped. postgresql, f#, npgsql, postgresql-9.6.
Read more >XX000: cache lookup failed for type 0` - Database ...
Automatic vacuum fails with `ERROR: XX000: cache lookup failed for type 0` · Strange. Do you have a problem with SELECT * FROM...
Read more >Thread: ERROR,XX000,"cache lookup failed for type 0"
hi , I had met a segment fault problem in PostgreSQL 12.1.And it happened randomly,I could not use the query to repeat the...
Read more >Re: ERROR: cache lookup failed for type 0
Hi Tom,. Hmm .. Interesting. A few weeks back I had a corrupted table (due to a disk error). I temporarily set zero_damaged_pages...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@vllama I did attempt to reproduce the error with the code you’ve provided, but so far no good. Is it possible to make a repro?
Closing as no repro was provided.