This project is archived and is in readonly mode.

#5044 ✓resolved
James Le Cuirot

Recent named_scope STI fix causes a massive slow down and memory leak

Reported by James Le Cuirot | July 4th, 2010 @ 02:00 PM

Commit 687d7f52c4a1d85666f1efc08ffa182e6dfeba57 (against 2-3-stable) from ticket #1570 is flawed and causes a massive slow down and memory leak. This caused my server to eat up all its RAM and swap before falling into a coma.

It's a fix to ensure that procs passed to named_scope are given the correct model when using STI. The "scoped" method uses a named_scope attached to ActiveRecord::Base so the self.model_name != parent_scope.model_name condition is always true in this case.

Here is a patch that checks to ensure self != Base but I'm wondering if this whole thing would still cause problems even when used in the right cases. Maybe the original commit should just be reverted?

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages