[migration] fix storage_change migraction to avoid exhausting the server's memory
--- 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)