views:

186

answers:

2

I have hundreds of thousands of objects based on plone archetypes (plone 2.5.X) that need their archetypes schema updated to the latest. The archetype schema migration tool is great for a small/medium number objects but is bringing my server to its knees trying to migrate them all, to the point where I always end up killign the script. I would like to be able to update the schema of one object at a time, potentially as the object as retrieved - is that possible? If not, any other approaches to updating archetype schemas in large plone sites?

Thanks in advance!

A: 

Although you don't explain what "bringing to it's knees" means, I'm going to guess that you run out of memory. If so, that's probably a question of the script not committing changes to disk. Adding a transaction.commit() in the loop (preferably with a test to only doing every 100th or 1000th time) should fix that.

Edit: So I was wrong, it wasn't a memory problem. It seems the archetypes updater does the correct thing.

Lennart Regebro
Unfortunately, its not just a memory issue.The update also causes the load (as disk IO) to spike significantly, and more importantly, end users see the effect of the update as slooooowness so I always manually intervene and kill it. There is always the possibility of a planned outage but I'm trying to avoid that for a silly schema update.I have just been running the standard archetype tool update code and can't seem to find how to update a single item, otherwise I would happily write loops and commit. can you post an example on how you would write that loop?Thanks!
Well, of course IO is gonna spike. Do you think you can make a massive update of the database without this getting written to disk? You don't seem to actually have a real problem. Run the archetypes upgrade.
Lennart Regebro
of course it is a problem when paying customers either receive crap response time for hours or a complete outage. I think its very fair to request to upgrade one item at a time and I thought this would be a simple answer with a small snippet of code. if its not possible then its not possible and I'll start looking at other options. I'm looking for code here - not a lecture on what my problem is.
Running the upgrade on one object at a time is of course possible. The code for this is available in the upgrade script, since that script finds all objects and upgrades them, one by one. Should be pretty easy to fix.However, a better solution is to actually run the upgrade and be finished with it. This is typically done either on the same staging server that you did the test of the software upgrade on, or on a separate ZEO client, which can be on a separate server even to make sure the production ZEO clients doesn't fell the load. The ZODB will feel it, of course, but that is unavoidable.
Lennart Regebro
+1  A: 
How / where are you hooking that code in?
rjmunro
@rjmunro I have custom archetype code, and I put this in different places depending on how fast I need the upgrade. Most places its it the at_post_edit hook. In one case, I want the upgrade to happen before the edit so I overwrote processForm so that it upgrades before the edit. This way I can add the new schema content manually to the edit form and then not have to worry about it not taking. I also did something similar for updating workflow only in that case, I put a call to a script at the top of the view template which triggers the update on view. let me know if you want code examples :)