Skip to content

Fix uncached to operate on the connection's own pool rather than ActiveRecord::Base's pool#25

Merged
jcoleman merged 2 commits intojcoleman:masterfrom
kilaru:fix-shard-aware-uncached
Apr 28, 2026
Merged

Fix uncached to operate on the connection's own pool rather than ActiveRecord::Base's pool#25
jcoleman merged 2 commits intojcoleman:masterfrom
kilaru:fix-shard-aware-uncached

Conversation

@kilaru
Copy link
Copy Markdown
Contributor

@kilaru kilaru commented Apr 27, 2026

Summary

  • ActiveRecord::Base.uncached only disables the query cache on ActiveRecord::Base's connection pool. When called on a connection belonging to a different pool (e.g. a sharded connection), the cache was not bypassed. Switching to uncached without the ActiveRecord::Base receiver fixes this, since AbstractAdapter#uncached delegates to the connection's own pool.
  • Bump sqlite3 development dependency to >= 2.1 to align with Rails 8 requirements.
  • Bump version

Test plan

  • Added a context "with a secondary connection pool" block that creates a separate connection pool and verifies each method bypasses the cache on that pool — the scenario that was broken before this fix.

…veRecord::Base's pool

ActiveRecord::Base.uncached only disables the query cache on ActiveRecord::Base's
connection pool. When called on a connection belonging to a different pool (e.g. a
sharded connection), the cache was not bypassed. Switching to uncached without the
ActiveRecord::Base receiver fixes this, since AbstractAdapter#uncached delegates to
the connection's own pool.

Bump sqlite3 development dependency to >= 2.1 to align with Rails 8 requirements.
Copy link
Copy Markdown
Owner

@jcoleman jcoleman left a comment

Choose a reason for hiding this comment

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

Comment thread spec/active_record_connection_adapter_spec.rb Outdated
@jcoleman jcoleman merged commit d754f0a into jcoleman:master Apr 28, 2026
54 checks passed
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

Successfully merging this pull request may close these issues.

2 participants