Skip to content
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

ISSUE: A PostgreSQL type with the oid '0' was not found in the current database info #3150

Open
Anton-Norko opened this issue Apr 5, 2024 · 0 comments

Comments

@Anton-Norko
Copy link

EF NPG package version: is 8.0.2, however, it could be a global issue related to npgsql package.
Server: PostgreSQL version is 15.2 (on Debian) and also 14.10 (on Red Hat).

Error message:

An unhandled exception has occurred while executing the request.
System.InvalidCastException: Reading as 'System.Object' is not supported for fields having DataTypeName '.<unknown>'
---> System.ArgumentException: A PostgreSQL type with the oid '0' was not found in the current database info

Steps to reproduce:

  1. Create a db with some schema and a table with a few columns using EF migration (probably manually schema creation will work too);
  2. Do select even on an empty table;
  3. Do not close your application after! This is important;
  4. Recreate schema with the same table using EF migration (probably manually schema recreation will work too);
  5. Do select on the same table;

It also could be reproduced when pooling was disabled or enabled - does not matter.

From what I already understood, technically it appears when npgsql wants to map the result of select and tries to get type info from the ByOID dictionary and there is no type here. Because(??) we already have the new schema, even with the same name and tables.

Any workarounds?

Full stack trace below:

2024-04-05 11:16:24Z [ERR] [Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred while executing the request.
System.InvalidCastException: Reading as 'System.Object' is not supported for fields having DataTypeName '.<unknown>'
---> System.ArgumentException: A PostgreSQL type with the oid '0' was not found in the current database info
   at Npgsql.Internal.NpgsqlDatabaseInfo.GetPostgresType(UInt32 oid)
   at Npgsql.Internal.NpgsqlDatabaseInfo.GetPostgresType(Oid oid)
   at Npgsql.Internal.NpgsqlDatabaseInfo.GetDataTypeName(PgTypeId pgTypeId, Boolean validate)
   at Npgsql.Internal.TypeInfoCache1.<GetOrAddInfo>g__CreateInfo|6_3(Type type, Nullable1 typeId, PgSerializerOptions options, Boolean defaultTypeFallback, Boolean validatePgTypeIds)
   at Npgsql.Internal.TypeInfoCache1.<GetOrAddInfo>g__AddEntryById|6_2(Type type, TPgTypeId pgTypeId, ValueTuple2[] infos, Boolean defaultTypeFallback)
   at Npgsql.Internal.TypeInfoCache1.GetOrAddInfo(Type type, Nullable1 pgTypeId, Boolean defaultTypeFallback)
   at Npgsql.Internal.PgSerializerOptions.GetTypeInfoCore(Type type, Nullable1 pgTypeId, Boolean defaultTypeFallback)
   at Npgsql.Internal.PgSerializerOptions.GetObjectOrDefaultTypeInfo(PostgresType pgType)
   at Npgsql.Internal.AdoSerializerHelpers.GetTypeInfoForReading(Type type, PostgresType postgresType, PgSerializerOptions options)
   --- End of inner exception stack trace ---
   at Npgsql.Internal.AdoSerializerHelpers.<GetTypeInfoForReading>g__ThrowReadingNotSupported|0_0(Type type, String displayName, Exception inner)
   at Npgsql.Internal.AdoSerializerHelpers.GetTypeInfoForReading(Type type, PostgresType postgresType, PgSerializerOptions options)
   at Npgsql.BackendMessages.FieldDescription.<GetInfo>g__GetInfoSlow|50_0(Type type, ColumnInfo& lastColumnInfo)
   at Npgsql.BackendMessages.FieldDescription.GetInfo(Type type, ColumnInfo& lastColumnInfo)
   at Npgsql.BackendMessages.FieldDescription.get_ObjectOrDefaultInfo()
   at Npgsql.BackendMessages.FieldDescription.get_FieldType()
   at Npgsql.NpgsqlDataReader.GetFieldType(Int32 ordinal)
   at Microsoft.EntityFrameworkCore.Query.Internal.BufferedDataReader.BufferedDataRecord.ReadMetadata()
   at Microsoft.EntityFrameworkCore.Query.Internal.BufferedDataReader.BufferedDataRecord.InitializeAsync(DbDataReader reader, IReadOnlyList1 columns, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.BufferedDataReader.InitializeAsync(IReadOnlyList1 columns, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.BufferedDataReader.InitializeAsync(IReadOnlyList1 columns, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.<>cDisplayClass30_02.<<ExecuteAsync>b0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementationAsync[TState,TResult](Func4 operation, Func4 verifySucceeded, TState state, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementationAsync[TState,TResult](Func4 operation, Func4 verifySucceeded, TState state, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.MoveNextAsync()
   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant