I have a site that was upgraded from Drupal 6 to Drupal 7. This site is quite large and has over 22,000 nodes.
When we try to run a bulk update of aliases, we get the following error:
An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=1000170&op=do StatusText: Internal Server Error ResponseText: 500 Internal Server Error Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.
In addition to the previous error every time we found with phpMyAdmin the following SQL query hanging on the server for long time:
SELECT COUNT( * ) AS expression
FROM (
SELECT 1 AS expression
FROM users u
LEFT OUTER JOIN url_ali
...and this other query:
State:
Copying to tmp table
Info:
SELECT n.nid AS nid
FROM
node n
LEFT OUTER JOIN url_alias ua ON CONCAT('node/', n.nid) = ua.s
It seems like these queries take too long and AJAX gives up after a while.
When running the bulk update for Taxonomy terms only (about 250 terms), it works very well.
Thanks for this great module. One of my favorites.
Comments
Comment #1
dave reidThere's not anything we can really do to make that query better. If you've got any ideas, let us know, otherwise this is kinda how this has to work.
Comment #2
Corwin commentedSELECT n.nid AS nid FROM node n LEFT OUTER JOIN url_alias ua ON CONCAT('node/', n.nid) = ua.source;
28013 rows in set (4 min 58.56 sec)
SELECT nid FROM node;
28008 rows in set (0.02 sec)
Why are we doing a left join when we are only taking data from the left table?
$ diff /tmp/2011-10-11_LEFT_OUTER_JOIN.txt /tmp/2011-10-11_SELECT_nid.txt
27924,27927d27923
< 1
< 1
< 1
< 1
27933d27928
< 3
The only difference on my site between the queries is:
1. The second query is 14,928 times faster
2. nid 1 comes up once instead of 5, and nid 3 comes up once instead of twice. Why would we even want the same nid coming up multiple times? The query only returns the nid.
Comment #3
dave reidYou're missing the important part of needing
WHERE ua.alias IS NULLwhich was missing from the original report. And I'm not sure why this query would be performing an outer join. It's now how the query is coded and it's not how its executed on my version of MySQL.Comment #4
micropony commentedI've hit the same wall (and same error) with bulk updating a site with ~9,000 nodes that need some nice new aliases.
I've tried accomplishing the task with drush, but hit another snag with that as well (looks like pathauto function names have shuffled a little). Described it here.
Comment #5
gaele commentedSame problem here. No time-out, but the bulk update is extremely slow.
70,000 nodes
MySQL 5.0.86
And an outer join:
Comment #6
phreadom commentedSame here... same AJAX error after running through around 3,000 of our 50,000 users. :(
It's also running incredibly slow, but I'll post that on the other ticket.
Comment #7
gaele commentedI've changed the query, and this seems to do the trick:
I didn't find out how to implement this using the database API.
Comment #8
gaele commentedWow! While typing this the bulk update finished: "Generated 59841 URL aliases."
In less than 30 minutes!
I'll check the results.
Comment #9
phreadom commentedDo I need to delete any existing aliases first? I have about half the aliases generated for content, users, etc... and when I try to finish aliasing them with this patch, I get the exact same behavior as before... incredibly high load on the CPU and very slow progress... it would take me 3 or 4 days at this speed to alias just my articles. A few more days for my users, etc. :(
Comment #10
gaele commentedHi phreadom, the adjusted version of node_pathauto_bulk_update_batch_process() worked for me. I didn't delete the existing aliases.
Comment #11
phreadom commentedI commented out
function node_pathauto_bulk_update_batch_process(&$context)inpathauto.pathauto.inc, and pasted in your new version, and tried running the bulk update for content, and later for users, and both behaved the same way as before, running high load for hours. :(Am I doing something wrong? I'd really love to get this working.
Comment #12
phreadom commentedI cleared my existing content aliases, and deleted any leftover batches from my batches table and then ran the content bulk alias update again and it's working!
It's gone through around 7,000 already in ~20 minutes and there's almost no load on the CPU either! Fantastic! Thank you!
UPDATE:
4 hours total, but that's a hell of a lot better than the 4 days it would have taken previously!
Now I'm going to try porting the same changes to the other functions for bulk updating my user aliases, as I have around 50,000 users, so the same problems definitely apply there as well. I'll update with the code if I get it to work.
Comment #13
gaele commentedLet's see what Dave thinks of this (#1).
I've put the temporary table creation in a separate, generic function, so it can be used for nodes, users, terms etc.
@phreadom: updating your 50,000 users should be fairly easy using this patch.
Comment #14
gaele commentedComment #16
phreadom commented@gaele: "Status message Generated 54934 URL aliases." took a few hours, but it made it through all of the user aliases as well. :D Thanks again!
Since it "works" for me at the moment, since I patched the other functions I needed as well, I'll just leave it as is for the moment and hope the maintainer adds these changes into the module itself in some form so that I won't have to maintain a set of custom patches for it.
Comment #17
gaele commentedI just ran the bulk update again. Generated 70970 URL aliases in 34 minutes.
Comment #18
gaele commentedComment #19
gaele commentedSorry, this is my first real encounter with the D7 database API. I couldn't find out how to create a temporary table that has an index on the (n)id in a different way.
Comment #20
sarhugo commentedWhy not adding the fields entity_type and entity_id to the url_alias table?
Comment #21
bago commentedAre you sure this is not the same of http://drupal.org/node/1415930 ?
Are you on mysql 5.0 ? I experienced the same issue you describe here, and it worked very fast after I applied http://drupal.org/node/1415930.
Comment #22
hop commentedWhen I run Bulk Update, I see error message: "An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=306&op=do StatusText: Internal Server Error ResponseText:".
When I generate URL aliases with module Views Bulk Operations (VBO) it was all OK :)
I recommend patch http://drupal.org/node/1415930#comment-5511014
Comment #23
natefollmer commented+1 for the patch in #22... I have 13,000+ users and over 29,000 nodes that needed updated and that patch made it happen!
Comment #24
mably commented