This project is archived and is in readonly mode.
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
-
James Le Cuirot July 4th, 2010 @ 02:55 PM
- Tag changed from activerecord 2-3-stable named_scope scoped memory leak patch to leak patch, 2-3-stable, activerecord, memory, named_scope, scoped
-
James Le Cuirot July 4th, 2010 @ 02:56 PM
- Tag changed from leak patch, 2-3-stable, activerecord, memory, named_scope, scoped to memory leak, 2-3-stable, activerecord, named_scope, patch, scoped
-
José Valim July 4th, 2010 @ 02:57 PM
- Importance changed from to Low
Which ruby version are you using?
-
Repository July 4th, 2010 @ 03:19 PM
- State changed from new to resolved
(from [bfbdeeae3080c89a0b27e42d684cbeb6206c6f60]) Use bind instead of instance_exec cause it may be causing memory leaks. Also, provide a simpler and sane implementation for scoped. [#5044 state:resolved] http://github.com/rails/rails/commit/bfbdeeae3080c89a0b27e42d684cbe...
-
Logan Bowers November 3rd, 2010 @ 11:35 PM
This commit regressed scoped() functionality, please see bug #5915
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>
People watching this ticket
Attachments
Referenced by
- 1570 named_scope not preserving proper model in STI This commit causes a massive slow down and memory leak. P...
- 5044 Recent named_scope STI fix causes a massive slow down and memory leak (from [bfbdeeae3080c89a0b27e42d684cbeb6206c6f60]) Use bin...