Skip to content

Conversation

flavorjones
Copy link
Member

Motivation / Background

Alt to #54350 and #54349, fixes #54343

Detail

This is variation on #54349 that extends ConnectionHandler::StringConnectionName to track primary_class?, and introduces ActiveRecord::Base.preventing_writes? that will accept a connection name and do the same thing that current_preventing_writes does on a record class.

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.

@flavorjones flavorjones force-pushed the flavorjones-dont-cache-class-in-pool-config-v3 branch from d9779de to 7526312 Compare January 27, 2025 14:01
@flavorjones flavorjones force-pushed the flavorjones-dont-cache-class-in-pool-config-v3 branch 3 times, most recently from f6c3b68 to 9ebeda0 Compare January 27, 2025 16:35
Keeping a reference to the class caused subtle issues when combined with reloading in
development. Instead, extend StringConnectionName to properly track
`primary_class?` and cache that.

Refactoring includes renaming `connection_class` to
`connection_descriptor`, and renaming the StringConnectionName class
to ConnectionDescriptor.

Fixes rails#54343.
@flavorjones flavorjones force-pushed the flavorjones-dont-cache-class-in-pool-config-v3 branch from 9ebeda0 to 2a90dbc Compare January 27, 2025 16:42
@byroot byroot merged commit b8b00ef into rails:main Jan 27, 2025
3 checks passed
@flavorjones flavorjones deleted the flavorjones-dont-cache-class-in-pool-config-v3 branch January 27, 2025 17:58
rafaelfranca pushed a commit that referenced this pull request Jan 27, 2025
…ss-in-pool-config-v3

`PoolConfig` no longer keeps a reference to the connection class (attempt 3)
@rafaelfranca
Copy link
Member

Backported to 8-0-stable since this is mostly an internal restructure to fix a bug

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.

PoolConfig caches the connection_class, which breaks if it is reloaded
4 participants