workarea-commerce / workarea

Workarea is an enterprise-grade Ruby on Rails commerce platform
https://www.workarea.com
Other
327 stars 66 forks source link

Fix Mongoid query cache data mutation #552

Closed bencrouse closed 4 years ago

bencrouse commented 4 years ago

Because the model shares the same underlying BSON::Document instance as the query cache, when you change data on the model, the query cache also changes. So if you do a find for the same model, you get a new instance with mutated data which doesn't match the database.

This is particularly noticable as it relates to our releases functionality, where documents loaded out of the database are intentionally mutated, but not saved.

bencrouse commented 4 years ago

One possible risk here, is the number of objects created in memory. Any better ideas?

bencrouse commented 4 years ago

closing because this has a pretty dramatic effect on memory:

Screen Shot 2020-11-04 at 3 28 00 PM