Closed (fixed)
Project:
XML sitemap
Version:
6.x-2.x-dev
Component:
Other
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Dec 2009 at 12:24 UTC
Updated:
4 Aug 2021 at 09:47 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
damienmckennaThis is happening on xmlsitemap_node.module line 198:
Despite the fact it is telling PHP to flush all of the cached nodes, it's still running out of memory.
It seems that I'm ultimately running into a PHP bug:
http://stackoverflow.com/questions/1145775/why-does-this-simple-php-scri...
:(
Comment #2
damienmckennaMaybe adding an extra command for just building the indexes and being able to set a limit would work around this?
Comment #3
dave reidCan you tell me what your CLI memory limit is? Also how many records are in your URL alias table?
Comment #4
damienmckenna'xmlsitemap' has 8521 records, 'node' has 65,641, the memory limit is 256mb (268435456 / 1024 / 1024).
Comment #5
dave reidHow many do you have in {url_alias}?
Comment #6
damienmckennaRoughly 98,000 =-)
Comment #7
dave reidCommitted a small change to xmlsitemap_get_path_alias() to fetch the url aliases using db_fetch_array() instead of db_fetch_object() so that should help a teeny bit with PHP and not using large amounts of stdClass.
Comment #8
damienmckennaDoing a bit better:
This time it completed about 55,000 (xmlsitemap) before failing. I should note that this time it did actually complete xmlsitemap_node's turn and failed on xmlsitemap_taxonomy.
Like I said, I'll see if I can come up with a command to do it in batches... and rewrite some of our own code to use db_fetch_array instead of db_fetch_object.
Comment #9
damienmckennaWould there be a problem rebuilding the entire xmlsitemap_node_xmlsitemap_links() process to just use an array rather than the full node? It isn't using much data anyway, only a few fields.
Comment #10
dave reidThe problem with doing custom stuff with node loading is that we need to be able to run node_access('view', $node, drupal_anonymous_user()). If we don't provide the fully loaded node object, I'm not sure if we can provide accurate results. I'm looking into generalizing the 'import new links' code and if there's some way we can use db_rewrite_sql() with it.
Comment #11
damienmckennaYeah, I saw that, was building up a list of the (at the time) five fields that were needed then my stomach dropped when I saw node_access() :-|
Comment #12
damienmckennaHere's a small patch that lets you pass either a node object or just the bare nid to taxonomy_node_get_timestamps.
Comment #13
damienmckennaComment #14
damienmckennaFYI this is related to #511956: Integrate Rebuild into Drush.
Comment #15
damienmckennaHere's a patch that adds two new Drush tasks:
These are modeled off the 'rebuild' task.
Comment #16
damienmckennaHere's an alternative version that just adds an option "--no-purge" to the existing "xmlsitemap rebuild" command.
The rationale for adding this is to let you repeatedly run the command "drush xmlsitemap rebuild --no-purge" until it completes building all of the sitemap entries, which can be useful for compiling the sitemap for the first time.
Comment #17
damienmckennaThe patch does not resolve the problem which is that the sub-modules still process all records and disregard anything that has been previously processed. For example, the taxonomy_node module uses the following query:
SELECT n.nid FROM {node} n WHERE n.nid > %d ORDER BY n.nidThe %d value is passed in from the batch so it can build them e.g. 500 at a time, but the process itself starts from scratch each time.
In effect, while it doesn't specifically purge the data before continuing, because every time it's executed it starts over from the beginning so will fail at roughly the same place each time.
Comment #18
dave reidYeah, I've got to split out the 'get new links' code from the sub-module's cron implementations so they can be called from cron or other functions.
Comment #19
damienmckennaHere's another patch that adds another argument, "module". By default, when this option is not passed it works the way it does currently and builds everything; if you pass in either "node", "term" or "menu" it will build those data structures using the built-in xmlsitemap submodules, otherwise it calls xmlsitemap_link_info on the module name passed in.
Comment #20
damienmckennaTiny tweak to the last patch, wraps check_plain around the argument and indicates which modules were executed at the end.
Comment #21
damienmckennaSuccess at last!
I added this alias on my server:
I was then able to successfully build the sitemap:
Thanks to a co-worker for suggesting the "-d memory_limit=1024M" argument on php.
Feel free to keep or can the patches as you see fit.
Comment #22
dave reidI just added an xmlsitemap-index command to *just* index old content and nothing else. It has an optional --limit parameter to control how many of each type can be indexed (i.e. if limit is 50, up to 50 links plus 50 menu items plus 50 terms, etc). Please test. This should help bring memory usage down since we don't need to regenerate the files afterwards.
Comment #23
moshe weitzman commentedmigrate.drush.inc spawns a subshell when memory gets low. its a handy technique thats easy with drush.
Comment #25
damienmckenna