Commit Graph

92632 Commits

Author SHA1 Message Date
Petrik 7f005e4be8 Move "avoid N+1 queries" explanation lower in the Active Storage documentation
The explanations about avoinding N+1 queries seems out of place early in
the documentation. The actual association hasn't been explained yet and
yet we explain performance optimizations.
It's also confusing when reading the following paragraph where "this
relationship" might seem to refer to the `with_attached_avatar` scope.

Instead we can group it as a performance section together with the
`strict_loading` section.
2024-08-19 13:41:48 +02:00
Vipul A M b60cf01e9d
Merge pull request #52647 from jdelStrother/activestorage-docs
Fix copy-paste error in ActiveStorage docs [ci skip]
2024-08-19 16:31:29 +05:30
Jonathan del Strother 783b2b245f
Fix copy-paste error in ActiveStorage docs [ci skip] 2024-08-19 11:57:05 +01:00
Petrik de Heus 18fcbd97b6
Merge pull request #52628 from jdelStrother/activestorage-docs
Clarify ActiveStorage::Attached::Model docs [ci skip]
2024-08-19 12:51:34 +02:00
Jean Boussier 607d61e884
Merge pull request #52634 from Shopify/uk-fix-method-added
Call `super` from `method_added`/`singleton_method_added` methods
2024-08-19 09:43:35 +02:00
Ryuta Kamizono 16882b886e
Merge pull request #52633 from neilvcarvalho/nc-ar-encryption-docs
Fix Active Record Encryption documentation [ci skip]
2024-08-18 17:52:43 +09:00
flavio-b 63041acfa7
Improves MIME type registration explanation
Co-authored-by: Petrik de Heus <petrik@deheus.net>
2024-08-17 15:04:46 -07:00
Petrik de Heus 02bf1c3ea3
Merge pull request #52636 from fractaledmind/patch-1
Update Active Record Store docs to mention SQLite JSON usage [ci skip]
2024-08-17 17:23:46 +02:00
Petrik c546aa6c6e Add digests to guide assets
This makes sure no stale stylesheets and javascript are shown to the
visitors.

This doesn't include images yet.

Co-authored-by: John Athayde <jmpa@meticulous.com>
2024-08-17 16:13:07 +02:00
Xavier Noria cffb642a0c Revise punctuation in CHANGELOG entry 2024-08-17 09:21:46 +02:00
Xavier Noria 7d282b449e Move removal target of SQLite's retries config to 8.1
This warning was just introduced, we need one release in
between for people to see it.
2024-08-17 09:03:54 +02:00
Jose Luis Duran aa8335f7a4 Cleanup service-worker.js trailing white space 2024-08-17 06:32:48 +00:00
flavio-b 5762ac17ad
Replace link with permalink and improve MIME type registration example 2024-08-16 19:28:04 -07:00
Stephen Margheim a33287d00c
Update Active Record Store docs to mention SQLite JSON usage
In addition to PosgreSQL JSON and MySQL JSON data types, developers need to use `store_accessor` instead of `store` when working with SQLite's JSON data type as well.
2024-08-17 01:57:22 +02:00
Ufuk Kayserilioglu 73b6000c49
Call `super` from `method_added`/`singleton_method_added` methods
If a `method_added`/`singleton_method_added` method on a constant doesn't call `super` then none of the `method_added`/`singleton_method_added` methods on ancestors of the constant ever get called by Ruby.

This breaks any code that might want to instrument classes to collect method definition locations, or to do other things when methods are added.

In order to be a good citizen, it is best practice to call `super` from these methods.
2024-08-17 01:39:15 +03:00
Aaron Patterson b26a9fd255
Merge pull request #52631 from zenspider/zenspider/minitest-cleanup
Bump minitest to 5.25.1 and clean up hacks.
2024-08-16 14:57:16 -07:00
Neil Carvalho 780f8b5e4b
Fix Active Record Encryption documentation
- Fix `ActiveRecord::Encryptor#decrypt` documentation

`ActiveRecord::Encryptor#decrypt` documentation mentions that it decrypts a `clean_text`, when, in fact, it decrypts an `encrypted_text`. This commit fixes this issue.

- Add missing `_` on the Active Record Encryption guides

The Custom Key Providers section mentions the expected API for custom key providers. The `decryption_keys` description is missing an underscore character.
2024-08-16 17:22:06 -03:00
Jean Boussier 36b030d3e3
Merge pull request #52632 from byroot/3.2-connection-lease-registry
Refactor query cache and connection lease registry for performance
2024-08-16 21:13:00 +02:00
Jean Boussier 99808b1ce7 Workaround a GC crash in ObjectSpace::WeakKeyMap
Being investigated at https://github.com/byroot/rails/pull/3

It seems that it's caused by using Thread or Fiber as keys.
2024-08-16 20:53:56 +02:00
Gannon McGibbon ea585d6386
Merge pull request #52629 from Shopify/opt_scanner
Optimize ActionDispatch::Journey::Scanner
2024-08-16 13:34:25 -05:00
Ryan Davis 2650a05547 Bump minitest to 5.25.1 and clean up hacks for minitest 5.25.0 2024-08-16 11:28:19 -07:00
Jean Boussier e356c63501 Refactor query cache and connection lease registry for performance
Fix: https://github.com/rails/rails/issues/52617
Followup: https://github.com/rails/rails/pull/52622

Previous fixes solved the memory issues, but our fallback implementation
of WeakKeyMap actually have terrible performance, and I can't find a way
to do it in a performent way.

So instead we replace it by a specialized weak map that only accept
Thread or Fiber as keys, and simple purge dead threads on insertion.

This gives us reasonable performance on Ruby 3.1 and 3.2.
2024-08-16 20:27:27 +02:00
Jonathan del Strother 41b1fac6ae
Clarify ActiveStorage::Attached::Model docs [ci skip] 2024-08-16 16:34:47 +01:00
Nick Pezza afecc8fd6c
Permit frozen models to be validated (#47969)
* Permit frozen models to be validated

* Remove initialize method since it's not needed

 Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-08-16 08:24:39 -07:00
Rafael Mendonça França c0effe0479
Merge pull request #52623 from frenkel/documentation-fix
Add Rails 7.2 release date to guides index
2024-08-16 12:08:24 -03:00
Jean Boussier f26faa8fc3
Merge pull request #52625 from Uaitt/remove-rubocop-offense-in-assets.rb
Remove Rubocop offense in `config/initializers/assets.rb` [ci skip]
2024-08-16 15:12:29 +02:00
Lorenzo Zabot e47a96378c Remove Rubocop offense in config/initializers/assets.rb 2024-08-16 14:54:07 +02:00
Jean Boussier 156b9ac638
Merge pull request #51958 from fractaledmind/activerecord-busy-handler-timeout
SQLite non-GVL-blocking, fair retry interval busy handler
2024-08-16 14:04:48 +02:00
Stephen Margheim 2976d3767e Use the new SQLite3::Database#busy_handler_timeout= method for a non-GVL-blocking, fair retry interval busy handler implementation
Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
2024-08-16 13:56:24 +02:00
Jean Boussier 8bf495a622
Merge pull request #52577 from n-studio/handle-sqlite-busy-as-deadlock
Handle SQLite3::BusyException to raise ActiveRecord::StatementTimeout
2024-08-16 13:49:14 +02:00
Jean Boussier 24ded0354e Hold query caches in a WeakKeyMap
Followup: https://github.com/rails/rails/pull/52622

Avoid leaking query caches when a ConnectionPool is gargabe collected.
2024-08-16 13:46:32 +02:00
Frank Groeneveld f17524e48c
Add Rails 7.2 release date
[skip ci]
2024-08-16 13:33:21 +02:00
Matthew Nguyen 41c547cb47 Translate SQLite3::BusyException into ActiveRecord::StatementTimeout 2024-08-16 13:22:44 +02:00
Jean Boussier b64eaddd73 Don't hold on connection pools from the query cache
Followup: https://github.com/rails/rails/pull/52622

This reference causes connections to linger around longer on Rails CI.
Instead we can simply share an atomic integer to bump the version.
x
2024-08-16 13:21:12 +02:00
Jean Boussier ffc580af94
Merge pull request #52622 from byroot/query-cache-isolated-context
Store query caches in IsolatedExecutionState to avoid memory bloat
2024-08-16 12:50:55 +02:00
Jean Boussier 49c9cf82bc Store query caches in IsolatedExecutionState to avoid memory bloat
Fix: https://github.com/rails/rails/issues/52617
Closes: https://github.com/rails/rails/pull/52618

It isn't per say a leak because the connection reaper eventually prune these,
and also it's not expected that new Threads are constantly making entries into that cache.
But it's true that with Fiber it's probably a bit more common, and the default reaper frequency
isn't adapted to clear this fast enough.

So instead of waiting for the reaper to trigger, which may take a long time, we keep the
caches in IsolatedExcutionState so that when the owning thread or fiber is garbage collected
its cache is too.

However since we need to be able to clear all threads caches, we keep a cache version
on the pool, and bump it to invalidate all caches of a pool at once.
2024-08-16 12:35:27 +02:00
Jean Boussier cc2c43b860
Merge pull request #52378 from fatkodima/fix-batches-error_on_ignore
Fix swallowing ignore order warning when batching using `BatchEnumerator`
2024-08-16 10:24:38 +02:00
Ryuta Kamizono 29f675999c Remove unused require 2024-08-16 12:20:30 +09:00
Jean Boussier ff64ad1d64 Fix a typo in Application#name doc 2024-08-16 00:42:16 +02:00
Gannon McGibbon 90b293ce82 Optimize journey scanner
Allocates less arrays and uses less regexes.
2024-08-15 16:27:09 -05:00
Jean Boussier d102960369
Merge pull request #52619 from fatkodima/eager-load-nil-associations
Allow to eager load nested nil associations
2024-08-15 22:40:36 +02:00
fatkodima 7bee100c33 Allow to eager load nested nil associations 2024-08-15 23:17:11 +03:00
Gannon McGibbon 9f9deaf6c1
Merge pull request #52605 from Shopify/scope_with_keywords
Use keywords with scopes and resources
2024-08-15 14:17:45 -05:00
Gannon McGibbon 36f5a2003f
Merge pull request #52610 from Shopify/no_more_racc
Remove racc
2024-08-15 13:04:26 -05:00
Jean Boussier 3dbff874b5
Merge pull request #52616 from byroot/fix-console-app-name
rails console: Handle non standard application names
2024-08-15 16:49:15 +02:00
Jean Boussier 1099b815b5 rails console: Handle non standard application names
Fix: https://github.com/rails/rails/issues/52615
Ref: https://github.com/rails/rails/pull/50796

The code assumed the application follow the standard `Name::Application`
naming, but it's possible to rename it however you like.
2024-08-15 16:48:49 +02:00
Jean Boussier 41921f9ec2
Merge pull request #52613 from byroot/fix-ar-base-lazy-schema-message
Fix ActiveRecord::Base.inspect to correctly indicate how to load schema
2024-08-15 10:27:58 +02:00
Jean Boussier 278ebf5651 Fix ActiveRecord::Base.inspect to correctly indicate how to load schema
Fix: https://github.com/rails/rails/issues/52601

Now that Active Record connections are fully lazy, just calling
`.lease_connection` isn't actually enough to estalish a connection.

We might as well suggest to use a method with the actual intent.
2024-08-15 10:15:05 +02:00
Jean Boussier 7c8704afc3
Merge pull request #52612 from SamvitaKarkal/fix_bin_setup_output_test
Fixed failure in bin setup test
2024-08-15 09:06:51 +02:00
Gannon McGibbon 7d42bf68e2 Manually implement journey parser
Removes racc dependency, and writes our own parser for routing instead.
2024-08-15 00:53:23 -05:00