Skip to content

[Fix #54502] Retrieve column from connection's schema cache when computing default attribute types #54510

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

Open
wants to merge 1 commit into
base: 7-2-stable
Choose a base branch
from

Conversation

joshuay03
Copy link

@joshuay03 joshuay03 commented Feb 12, 2025

Motivation / Background

Fixes #54502 (I've tested against that repro script)
Some discussion in https://discord.com/channels/849034466856665118/974005005768069211/1339360740057944075

Detail

Ensures columns used when defining default attribute types are retrieved from the schema cache for the current connection instead of from the model schema, which may have been set by different connection in another thread.

I've targeted 7-2-stable cause this doesn't really make sense on main, and we'd want to do the same for 8-0-stable. Alternatively as I mentioned in the issue we could backport 9ad36e0.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

columns_hash.transform_values do |column|
column = connection_columns[column.name] || column
Copy link
Author

@joshuay03 joshuay03 Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@columns_hash is set after doing some filtering on the schema cache columns on schema load, so we need to iterate on the filtered set while still retrieving columns from the schema cache. See failing build: https://buildkite.com/rails/rails/builds/116564.

@joshuay03 joshuay03 changed the base branch from main to 7-2-stable February 13, 2025 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect concurrent Postgres type map lookups by Hstore OID with multiple shards
1 participant