[migration] fix storage_change migraction to avoid exhausting the server's memory stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 20 May 2010 10:41:36 +0200
branchstable
changeset 5551 e41cd3bf5080
parent 5550 b143444dc08a
child 5552 11175c77be9c
[migration] fix storage_change migraction to avoid exhausting the server's memory
server/migractions.py
--- a/server/migractions.py	Thu May 20 10:40:57 2010 +0200
+++ b/server/migractions.py	Thu May 20 10:41:36 2010 +0200
@@ -1200,11 +1200,15 @@
         source = self.repo.system_source
         storage = source.storage(etype, attribute)
         source.unset_storage(etype, attribute)
-        rset = self.rqlexec('Any X,A WHERE X is %s, X %s A'
-                            % (etype, attribute), ask_confirm=False)
+        rset = self.rqlexec('Any X WHERE X is %s' etype, ask_confirm=False)
         pb = ProgressBar(len(rset))
         for entity in rset.entities():
+            # fill cache. Do not fetch that attribute using the global rql query
+            # since we may exhaust memory doing that....
+            getattr(entity, attribute)
             storage.migrate_entity(entity, attribute)
+            # remove from entity cache to avoid memory exhaustion
+            del entity[attribute]
             pb.update()
         print
         source.set_storage(etype, attribute, storage)