-
Type: Bug
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: 8.0.1, 8.1.0, 8.0.2, 8.0.3, 8.0.4, 8.0.5, 8.1.1, 8.0.6, 8.1.2
-
Component/s: Associations
-
None
Attempting to save a new document with a large number of embedded documents fails with a SystemStackError when the has_many association has cascade_callbacks: true. Here's a quick example:
class Foo include Mongoid::Document embeds_many :bars, cascade_callbacks: true end class Bar include Mongoid::Document embedded_in :foo end foo = Foo.new 1500.times { foo.bars.build } foo.save # SystemStackError: stack level too deep
The limit seems to be 1,117 embedded documents.
The problem was introduced in Mongoid 8. The above code works just fine with Mongoid 7.
- is related to
-
MONGOID-5688 Spike: Consider implementing callbacks with Ruby Fibers
- Closed
- related to
-
MONGOID-5700 Commit & rollback callbacks defined in mongoid 8.1 before code to run them is added
- Closed
-
MONGOID-5722 Implement callbacks with Ruby Fibers
- Development Complete