A production Rails 7.2.1.1 upgrade caused SystemStackError crashes due to a change in how ActiveRecord builds OR queries. The recursive implementation in 7.2.1.1 created deeply nested structures that exceeded stack limits, especially in Async fibers. The issue was traced to PredicateBuilder creating left-deep nested OR trees instead of flat structures. Rails 7.2.2+ fixes this by flattening the OR node structure, but a workaround using simpler queries with in-memory filtering works for earlier versions.

7m read timeFrom bigbinary.com
Post cover image
Table of contents
Identifying the problemGoing into Rails InternalsThe Tree Structure ProblemThe Async ConnectionThe GitHub TrailOur SolutionMeasuring and VerifyingReferences

Sort: