[Internals] Dependent instances leaking
After destroying a Context or Project, all related Todos are deleted as a consequence of :dependent => :delete_all. However, the deletion of Todos done this way does not propagate deletion to associated Dependents. This is because :delete_all deletes all related Todo objects without executing callbacks; therefore the :dependent option of Todo.successor_dependencies and Todo.predecessor_dependencies is ignored. As a result, the database gets polluted with Dependency objects that have successor or predecessor associations as null.
This does not change the behavior of the application in any way. Having leaks in the database does affect performance and footprint, though.
Suggested fix: User.todos and Project.todos associations would have to be :dependent => :destroy_all. This change would only affect the successor_dependencies and predecessor_dependencies associations, making sure no Dependent object is left behind when a Todo is deleted as a corollary of destroying a User or a Project.
Thanks,
- Ivan
This does not change the behavior of the application in any way. Having leaks in the database does affect performance and footprint, though.
Suggested fix: User.todos and Project.todos associations would have to be :dependent => :destroy_all. This change would only affect the successor_dependencies and predecessor_dependencies associations, making sure no Dependent object is left behind when a Todo is deleted as a corollary of destroying a User or a Project.
Thanks,
- Ivan
Leave a comment