I'm getting an error when installing xmlsitemap_node
* warning: pg_query() [function.pg-query]: Query failed: ERROR: duplicate key violates unique constraint "xmlsitemap_node_pkey" in /home/davidt/www/drivesouth/includes/database.pgsql.inc on line 125.
* user warning: query: INSERT INTO xmlsitemap_node (nid, pid, last_changed, last_comment, previous_comment) SELECT n.nid, ua.pid, n.changed, s.last_comment_timestamp, MAX(c.timestamp) FROM node n LEFT JOIN node_comment_statistics s ON s.nid = n.nid LEFT OUTER JOIN comments c ON c.nid = n.nid AND c.timestamp < s.last_comment_timestamp LEFT JOIN xmlsitemap_node xn ON xn.nid = n.nid LEFT JOIN url_alias ua ON ua.src = 'node/' || n.nid WHERE xn.nid IS NULL GROUP BY n.nid, ua.pid, n.changed, s.last_comment_timestamp in /home/davidt/www/drivesouth/includes/database.pgsql.inc on line 145.
Drupal 5.2 / PostgreSQL 8.2
Any ideas?
DT
Comments
Comment #1
darren ohRun this query and report your result:
Comment #2
darren ohComment #3
davidwhthomas commentedThanks for the reply.
The query returned 1 result.
Please see the attached screenshot.
regards,
DT
P.S I think this may be related to the node paths being the plain path as opposed to the clean urls path in the sitemap file.
Would be great to get it resolved!
Comment #4
davidwhthomas commentedComment #5
darren ohNow let's see if we can find out why that node is being duplicated. Try this query:
Comment #6
darren ohComment #7
davidwhthomas commentedThanks for the reply,
Here's the output from the query
(see attached screenshot)
DT
Comment #8
darren ohIt didn't show any duplicate entries. I've seen a similar unexplained error in issue 192928.
Comment #9
davidwhthomas commentedstill getting the first error in the logs each cron run.
Is there a way to fix it?
Comment #10
darren ohTesting is needed to find a query that works. Contact me directly if you would like help with this.
Comment #11
davidwhthomas commentedThanks for the reply,
I've had to disable the cron functionality for the time being because of this error.
(renamed hook_cron to hook_cron_disabled)
I can't give you direct access to our database / system as it's behind firewalls and the only way in is ssh.
But I'm happy to test different queries if you can post them here and give you the results promptly.
thanks again for your help, it would be great to get this resolved.
regards,
DT
Comment #12
darren ohPosting here is too slow. I can use PHP code to run queries from within Drupal, or we can chat and you can run the queries. Either way, it would be best for you to contact me directly.
Comment #13
cheechq commentedI was having the same problem with Drupal 5.3 and mySQL. The problem is that the query does not account for multilpe rows in the url_alias with the same value in the src field. I did not fix the query (davidwhthomas and project administrators can do this) but I did find a work around for my scenario. In my case, I had multilpe rows in the url_alias with the same value in the src field because I have the pathauto module installed and I entered a value in the "URL path settings" form field on the create content (aka node) that is different from what pathauto would generate. When I did this two rows were inserted into the url_alias table with the same src field value, one created automatically by pathauto and one for the value I entered in the "URL path settings" form field. To work around this I just updated my nodes and cleared the "URL path settings" from each node. Then I used the link created by pathauto when reference this content throughout my site.
Comment #14
oboema commentedI an also having problems with the xml site map module;
When I run Cron i get the following error
Comment #15
deviantintegral commentedI've attached a patch which seems to fix the issue for me. I'm using MySQL. This is against stable.
Of course, now I realize it's the same as the query above for pgsql :P
I haven't touched the pgsql code as I have no way to test it.
Thanks!
--Andrew
Comment #16
davidwhthomas commenteddeviantintegral: thanks for this, it looks like a reasonable solution.
Ths code is standard sql and will work in postgresql or mysql.
With the modification, duplicate url alias pids should be subsumed into grouping by nid with this patch which should overcome the duplicate nid key error.
I will test it out tomorrow and post back - looks promising :-)
DT
Comment #17
darren ohPostgreSQL will not select a single value from a group of values. Thus, when results are grouped, we must group by each column from which we wish to select a single value. If we do not wish to group by ua.pid, we must use an aggregate function to retrieve a value from each group of results.
MySQL, on the other hand, will select a single value from a group of results if asked to do so. However, the value it selects is random and unpredictable, so it's poor design to rely on this MySQL quirk.
We just need to decide on the right aggregate function:
MySQL 5.0 Reference Manual
PostgreSQL 8.2: Aggregate Functions
Comment #18
davidwhthomas commentedThe patch by deviantintegral
worked for me.
Are there any issues I should consider? or is it ok to use this?
DT
Comment #19
davidwhthomas commentedIn answer to my own question, with the patch applied I get:
It looks like you're right there with an aggregate function being required, Darren.
any suggestions?
DT
Comment #20
davidwhthomas commentedadding the aggregate function max() worked.
This should select the latest and greatest pid.
note: the max(ua.pid)
DT
Comment #21
darren ohIdeally, we would get the same result as
drupal_lookup_path(), which simply returns the first result.Comment #22
darren ohIdeally, we would get the same result as
drupal_lookup_path(), which simply returns the first result.Comment #23
davidwhthomas commentedThanks for the reply,
Just to let you know,
gets the first / top result and is working for me.
DT
Comment #24
darren ohJust to clarify, was that tested on a node with multiple URL aliases?
Comment #25
davidwhthomas commentedI assume so, it's the same DB (more or less) that raised the original error in this thread.
Is there a query I can run to check if duplicate aliases are in the url_aliases table?
I tried:
but couldn't see any dupes.
DT
Comment #26
darren ohTry this:
SELECT * FROM url_alias GROUP BY src HAVING count(pid) > 1If that doesn't show duplicates, we haven't identified the cause of this bug.
Comment #27
davidwhthomas commentedThe query gave :
'pid must appear in group by clause...' etc...
so I tried:
and got:
0 results.
However, this query:
gave 1 result
and lastly:
DT
Comment #28
darren ohSorry for giving you a bad query. Now the the question is, does
SELECT dst FROM {url_alias} WHERE src = 'node/1120' LIMIT 1produce A1GP-competition or info/1120/competitions?
Comment #29
davidwhthomas commentedNo problem, thanks for your help on this! xmlsitemap is a great module and worth refining :-)
Here's the latest query result
Comment #30
darren ohFixed in CVS commit 94686. This whole issue will become irrelevant when issue 198173 is fixed.
Comment #31
darren ohComment #32
darren ohComment #33
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.