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

Possible race condition in postgresql type_map initialization #51780

Open
scpike opened this issue May 10, 2024 · 0 comments
Open

Possible race condition in postgresql type_map initialization #51780

scpike opened this issue May 10, 2024 · 0 comments

Comments

@scpike
Copy link
Contributor

scpike commented May 10, 2024

Steps to reproduce

Since upgrading from Rails 7.0 to 7.1 we've started to see the following exception:

# activerecord (7.1.3.2) lib/active_record/connection_adapters/postgresql_adapter.rb in get_oid_type
undefined method `key?' for nil:NilClass (NoMethodError)
          if !type_map.key?(oid)
                      ^^^^^

I haven't been able to replicate the behavior outside of production where it occurs when the application briefly loses its connection to the postgres database while under load. This is a multi-threaded environment. The server never recovers after entering this state.

I know there was a change to type_map initialization at dc4420c, and it looks to me like it's possible there's a race condition here. I'll update this issue with steps to replicate if I can manage to trigger this outside of production.

Expected behavior

The application should recover from a brief database outage and reconnect.

Actual behavior

The server is never able to reconnect.

System configuration

Rails version: 7.1.3.2

Ruby version: 3.2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants