rails changelog


Welcome to the latest update! ๐ŸŽ‰ We've been busy squashing bugs, improving performance, and tidying up the codebase to make your development experience smoother and more delightful. Here's a rundown of the latest changes:

  • New feature: We've improved the behavior of method_added and singleton_method_added methods by ensuring they call super. This change is crucial for maintaining the functionality of code that tracks method definitions or performs actions when methods are added. Now, ancestor callbacks will be executed as expected, enhancing the compatibility and predictability of Ruby code. ๐Ÿš€

  • Bugfix: We tackled a pesky issue causing garbage collection crashes when using ObjectSpace::WeakKeyMap with Thread or Fiber objects as keys. Our workaround involves a custom WeakThreadKeyMap class, ensuring stability in the ActiveRecord connection pool while the root cause is investigated. ๐Ÿ›๐Ÿ”จ

  • Improvement: Connection pools no longer linger around unnecessarily, thanks to a revamped query cache mechanism. We've shifted to using an atomic integer for versioning, reducing the load on Rails CI and boosting performance. ๐Ÿ’ช

  • Improvement: Performance woes be gone! We refactored the query cache and connection lease registry, replacing the inefficient WeakKeyMap with a specialized weak map that handles Thread or Fiber keys with finesse. Enjoy smoother operations on Ruby 3.1 and 3.2! โšก

  • Chore: A little spring cleaning never hurt anyone! We removed an unused require statement from the resources_test.rb file, tidying up the codebase and optimizing load times during testing. ๐Ÿงน

  • Bugfix: Say goodbye to center alignment issues in guides blocks. We've fixed the wonky alignment, making the guides more visually appealing and easier to read. Your eyes will thank you! ๐Ÿ‘€

  • Bugfix: We fixed several RuboCop offenses in actionpack/lib/action_dispatch/journey/parser.rb. By adding a frozen string literal comment and addressing layout issues, we've made the code more readable and maintainable. ๐Ÿ“

We hope these updates enhance your development journey. Keep coding and enjoy the improvements! ๐ŸŽˆ

Included Commits

2024-08-16T03:20:30 See commit

This commit involves the removal of an unused require statement from the resources_test.rb file located in the actionpack/test/controller directory. Specifically, the line that required the active_support/core_ext/array/extract_options module was deleted, as it was determined to be unnecessary for the functionality of the test.

The change results in a cleaner codebase by eliminating redundant dependencies, which can improve maintainability and potentially reduce load times during testing. Overall, this commit contributes to enhancing the overall efficiency of the testing environment within the Action Pack framework.

Files changed

  • actionpack/test/controller/resources_test.rb
2024-08-16T11:21:12 See commit

This commit addresses an issue in the Rails framework where connection pools were being held longer than necessary due to the query cache mechanism. The change introduces a more efficient way to manage the versioning of the query cache by utilizing an atomic integer. This approach eliminates the need to hold onto the connection pools, thereby reducing the lingering connections observed in the Rails CI environment.

Specifically, the modifications include updating the Store class in the query_cache.rb file to accept an atomic integer for version tracking instead of the connection pool itself. This not only streamlines the initialization of the query cache but also ensures that the cache is cleared appropriately when the version changes, enhancing overall performance. The test cases were also updated to reflect this change, ensuring that the new implementation functions correctly.

Files changed

  • activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
  • activerecord/test/cases/query_cache_test.rb
2024-08-16T17:49:28 See commit

This commit focuses on enhancing the performance of the query cache and connection lease registry in the Rails framework, addressing previous memory issues while also tackling performance drawbacks associated with the fallback implementation of WeakKeyMap. The original implementation was found to be inefficient, prompting a shift to a specialized weak map that exclusively accepts Thread or Fiber as keys. This new approach allows for the effective purging of dead threads upon insertion, resulting in improved performance on Ruby versions 3.1 and 3.2.

The changes primarily involve modifications to the connection_pool.rb file, where the previous WeakKeyMap has been replaced with a WeakThreadKeyMap. This refactor simplifies the management of key-value pairs, streamlining operations such as clearing and accessing values while ensuring that only alive threads are retained in the map. Overall, this update not only resolves existing performance issues but also enhances the efficiency of connection handling within the ActiveRecord framework.

Files changed

  • activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
2024-08-16T18:53:56 See commit

This commit addresses a crash issue related to garbage collection (GC) that occurs when using ObjectSpace::WeakKeyMap in Ruby, particularly when Thread or Fiber objects are used as keys. The problem is currently under investigation, as noted in the linked GitHub pull request. To mitigate the issue, the code has been modified to implement a custom WeakThreadKeyMap class instead of relying on the problematic WeakKeyMap, while still maintaining the overall functionality of the connection pool in ActiveRecord.

The changes made in the connection_pool.rb file include the removal of conditional checks for WeakKeyMap and the establishment of a straightforward implementation of WeakThreadKeyMap. This custom class maintains a simple hash map, allowing for the management of weak references while avoiding the GC crashes associated with the standard WeakKeyMap. Overall, this workaround ensures stability in the ActiveRecord connection pool while the underlying issue is being resolved.

Files changed

  • activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
2024-08-16T22:39:15 See commit

This commit addresses an important issue regarding the behavior of method_added and singleton_method_added callbacks in Ruby. When these methods are defined on a constant and do not call super, it prevents the corresponding callbacks in ancestor classes from being invoked. This can disrupt functionality in code that relies on tracking method definitions or performing actions when methods are added, ultimately leading to unexpected behavior and breaking such instrumentation.

To promote better practices and ensure that ancestor callbacks are executed, the commit modifies the implementation to enforce the calling of super within method_added and singleton_method_added methods. This change aims to enhance compatibility and maintainability of Ruby code, allowing for a more consistent and predictable method addition process across class hierarchies.

Files changed

2024-08-20T03:23:57 See commit

This commit addresses and corrects several RuboCop offenses found in the actionpack/lib/action_dispatch/journey/parser.rb file, which is no longer an automatically generated file following commit #52610. As part of the cleanup, a frozen string literal comment was added at the beginning of the file, and various layout and indentation issues were fixed to adhere to the style guidelines.

Specific changes include the removal of unnecessary blank lines after private access modifiers, and adjustments to ensure consistent indentation throughout the file. The corrections involve aligning method definitions and maintaining a uniform indentation width, enhancing the overall readability and maintainability of the code.

Files changed

2024-08-21T19:14:37 See commit

This commit addresses a center alignment issue in the guides blocks of the project. The changes implemented ensure that the content within these blocks is properly centered, enhancing the overall visual consistency and user experience. By correcting the alignment, the guides are now more aesthetically pleasing and easier to read.

Additionally, the commit may include adjustments to related styles or layouts to maintain harmony across different components. This fix is an important step towards improving the usability and presentation of the guides section, ultimately benefiting users who rely on this content for information and navigation.

Files changed