ged / ruby-pg

A PostgreSQL client library for Ruby
Other
796 stars 180 forks source link

TypeError PG::TypeMap undefined method `key?' for nil if !type_map.key?(oid) #582

Closed navidemad closed 2 months ago

navidemad commented 2 months ago

System

OS: Heroku Ubuntu 22 Ruby: 3.3.4 ruby-pg: 1.5.7

Backtrace

TypeError · wrong argument type nil (expected PG::TypeMap) Unhandled error
NoMethodError: undefined method `key?' for nil if !type_map.key?(oid)

Explanation

Hello, we are facing some weird issues happening randomly. On line that are doing a basic find on the database, which is working 99.99% of the time.

parking = Parking.find_by(id: params[:parking_id])

Does it ring any bell in the code source ?

larskanis commented 2 months ago

The text if !type_map.key?(oid) if here in ActiveRecord:

https://github.com/rails/rails/blob/ac1d7681d05906b2b050eced76c6a2165f420821/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L830

And the TypeError comes probably from here:

https://github.com/rails/rails/blob/ac1d7681d05906b2b050eced76c6a2165f420821/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb#L16

That's all I can say for now. No idea why the type map should be nil in either case.

navidemad commented 2 months ago

I made a follow up issue on the rails repository : https://github.com/rails/rails/issues/52595 This issue seems to be related : https://github.com/rails/rails/issues/51780