Hello. I'm upgrading from a 6.x-2.x-dev release, from approximately the September 11th CVS commits. After moving to 2.0-alpha1, I'm trying to regenerate activity message - specifically "Record an activity message when: node insert types Mytype". The batch API fires up, gets the bar to 50%, and just stays there. It never finishes - just keeps going in a loop. I'm not sure if it ever successfully regenerates anything but it doesn't look like it does. This is with Pressflow 6.16.96, and I snapped down to a dev environment with all of the performance stuff disabled (i.e. no varnish, no memcache, etc.) Tested with both Firefox and Chrome.
I haven't dug into the code yet to determine what's going on but I thought I'd start with this post in case someone had an idea. Thanks in advance.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | activity-regenerate-limiters.patch | 3.54 KB | sirkitree |
| #22 | activity-batchapi-limiters.patch | 2.34 KB | sirkitree |
| #9 | 1002952-9.patch | 1.97 KB | rjbrown99 |
Comments
Comment #1
rjbrown99 commentedWell I know why it's happening now, but not sure what it means yet.
My activity table has a field 'actions_id', but in my case all of the existing activities have a value of 0 in that field. Inside the activity_batch_delete() function, it runs a SQL query (:
In my case, %d = 0 and %s = 14. So that SQL fails since activity_id is 0.
I'm guessing that at some point actions_id was introduced and my existing activity doesn't have that represented.
Comment #2
rjbrown99 commentedOK, well here's why.
http://drupal.org/node/463854#comment-2972118
Let's assume that it isn't possible in the current state of the code - perhaps it's still a good idea to introduce some better error checking so the batch finishes? Or is this a moot point since very few of us use the older code.
Comment #3
rjbrown99 commentedWell, I want to regenerate ALL of my activity, so I just hosed all of the old node activity.
I thought that might do it and get me going, but I thought wrong. It's now failing in activity_batch_regenerate(). The $batches array it gets something that looks like this:
In this case, it takes 14 as the $aid, which seems to not be correct so I'm guessing there is an issue in either what is being passed in to regenerate or something to do with the foreach. Hmm.
EDIT: For what it's worth, this same behavior happens even if I disable the Activity module, uninstall it (no more DB tables), reinstall/re-enable, and then re-add a node activity message and select record. So I don't think it's related to an upgrade.
Comment #4
rjbrown99 commentedOK, that wasn't it at all.
The activity_batch_regenerate function starts out with $batch, which in my case includes one array entry for each node on the system. With a node count into the hundreds of thousands, this runs into a scalability wall. It passes this entire list of nodes off to the regenerate function regardless of whether or not the content type is being regenerated. For example, I want to regenerate one content type called 'item'. Even though that's my desire, it's batching on all of the nodes which makes it incredibly slow to regenerate as we fall through to the activity_record_check() function before this is caught.
I'm in the process of rewriting a bit of this checking up-front before the batch process begins. Inside of activity_batch_regenerate, before we set the final $batch, I pull the parameters from the actions table, determine the node type for this $aid, run a SELECT to pull all nodes of that type, and then do a foreach to remove anything that isn't part of this node type. This is done before we batch_set(), so we are only batching up the nodes that need content regenerated. This is a massive savings in time on my site when regenerating activity.
I'll roll up a patch as I get a bit further, but here's what it looks like if you are curious.
Comment #5
rjbrown99 commentedComment #7
petiar commentedHi rjbrown99,
nice self-answering issue thread, useful though!
Just quick question - it is not 100% clear to me whether your patch solved the issue of regenerate hanging on 50%, did it?
Thanks,
Petiar.
Comment #8
rjbrown99 commentedYes, this has solved it. It wasn't actually hanging - it was slowly churning through batches of nodes - 50 at a time. Nothing was being generated because the batches were full of nodes from content types that did not need to be updated in the first place. My 'fix' just reduces the giant array of nodes so it only includes the ones that are part of the content type you want to update. In my case it completes almost immediately now.
I'll roll up a patch today for this.
Comment #9
rjbrown99 commentedOK, give this a shot and let me know how it works out for you. It's rolled against 6.x-2.0-alpha1.
Comment #10
Scott Reynolds commentedDid you look into updating your table? Seems like the best solution is to write a script that does much of what you are trying to do but updates the aid table instead.
Comment #11
rjbrown99 commentedIt wasn't with my table - I reinstalled activity from scratch including all of its tables.
The core problem is that I have 200,000 nodes, and all of them are being passed in to set_batch() even though I'm only updating a content type with say 1000 total nodes. So the batch runs across 200,000 nodes when it only needs to run over 1000. This patch fixes that so it only passes the 1000 nodes to set_batch in the first place. The result is the messages for those nodes are now generated MUCH faster since we're only batching on the nodes for the content type in question.
This is different than the issue I originally presented, I was off on the wrong path at that point. It wasn't related to upgrading.
Comment #12
Scott Reynolds commentedOk then the solution needs to add more intelligence to
There it should pass in the params from the actions table.
Comment #13
Scott Reynolds commentedComment #14
rjbrown99 commentedI can't quite explain why, but when regenerating comments this was not a problem for me - they completed quickly. It was just the node rebuilds that were problematic. I don't build user actions so I did not test that.
#7 - since you had the same problem, can you give this a go? Test it for both node, comment, and user rebuilds and see what happens (before and after the patch preferably.)
Comment #15
petiar commented#14 What was happening before the patch is described here: #1003334: Regenerate takes too long and I am not sure whether it actually regenerates..
There is 18560 comments on my web (imported via migration scripts from the old version) which have uid > 0 (so they're not anonymos). And there are 33 726 nodes among 13 content types.
When I hit Rebuild Activity Access Table (after applying your patch) I have got 355 records in the {activity} table which seems to be really low number. I am not sure what the Rebuild should do but I was expecting to rebuild all activity of all users backwards. As there is each node assigned to registered user and also plenty of comments from them, I would expect huge number of rows in the {activity} table. But I am not sure whether this works that way.
But it definitely doesn't hang after your patch anymore.
Comment #16
Scott Reynolds commentedThis patch doesn't touch "Rebuild Activity Access Table" process. And that button doesn't do what you expect it too. you have to goto admin/build/activity and click regenerate
"Rebuild Activity Access Table" rebuilds the access control on existing activities. The regenerate regenerates activities in an existing site.
Comment #17
petiar commentedDoh!!!
Of course, wrong button. Anyway, I have tried the regenerate with the "regenerate" link in Activity Publisher Templates list and I have got blank screen. My PHP RAM limit is 96M. However, this is happening without the patch as well, so I guess I need to ask my tech support to increase the PHP RAM limit or I could create separate template for every single content type and thus decrease the number of nodes to regenerate. I'll give it a try tommorrow and let you know.
Thanks guys.
Comment #18
petiar commentedOk, I am back finally. :-)
Today I have tried to regenerate some activities - for users module it went well, activities were regenerated, but with node API strange thing happened - after click on regenerate I have got Drupal's Permission denied page. I am logged as a user #1. Any thoughts?
Comment #19
Scott Reynolds commentedrefresh the prior page. The link uses a token to protect against cross site scripting. That is undoubtedly why you are getting an access denied page.
Comment #20
sirkitree commentedI think what Scott is meaning to say is that instead of patching up the batchapi function, activity_batch_regenerate(), it would be better to have this limiting logic within node_list_activity_actions(), user_list_activity_actions(), and comment_list_activity_actions() respectively and pass into them a parameter that can be used to limit, such as node type.
However, I think I might take this even one step farther and actually have the ability to define a list of nodes to pass in. I've come across a use case where it would be useful to not only limit by node type, but even more fine grained, be able to generate activity on a list of nodes for a certain timeframe. I'll work on that in a separate issue after I have this one worked out, since working this one out will basically do the hard part of the next issue.
Comment #21
sirkitree commentedSo my idea is ending up being a bit of a change to the API. And as much as I dont' really want to do that for the D6 version, it's needed by a client.
The change I'm proposing is in hook_list_activity_actions() and instead of passing in $max_age, we pass in an array of keyed $limiters. So we can then pass:
It's a bit difficult coming up with what all we should include as limiters, and it also somewhat changes per use, but I think it at least allows for an acceptable way of extending this hook. Thoughts?
Comment #22
sirkitree commentedHere is a patch illustrating changes for proof of concept (this will not work yet and is untested) but wanted to illustrate what I'm thinking so far...
Comment #23
sirkitree commentedHeh, so after going down that rapid hole, it was way easier to just expand upon the current patch.
This basically does what the patch in #9 does, but changes the regenerate links callback to go to a form first, which allows for a comma separated list of node id's to limit the batch even further. So we get the combined effect here of limiting by the node type, and the option to limit by node id as well.
How you find those node id's is not addressed.
Comment #24
Scott Reynolds commentedThis is a bad idea as well.
I suggested this: http://drupal.org/node/1002952#comment-3874742
And what I meant with that is those functions should take in a actions_id, figure out the types, and apply it to the query. THUS, only returning nodes / users / comments / flags / fb_style_status that match that actions_id.
Comment #25
_shyD6 reached its EOL back in February 2016, and there is no active release for D6 for this module anymore.
Development or support is not planned for D6. All D6-related issues are marked as outdated in a bunch.
If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.
Thanks!