Having an issue with the MySQL server in which one or more tables (seemingly node) is locked and prevents the rest of the Drupal site from working correctly, apparently on account of a query issued by Biblio module. The query runs indefinitely and prevents other queries attempting to access one or more of the involved tables. As per the SHOW FULL PROCESSLIST MySQL command the offending query is as such:

SELECT COUNT(*) AS expression 
FROM  (
	SELECT 1 AS expression FROM  node n 
    LEFT OUTER JOIN biblio b ON n.vid=b.vid 
    INNER JOIN biblio_types bt ON b.biblio_type=bt.tid 
    INNER JOIN biblio_contributor bc ON n.vid = bc.vid 
    INNER JOIN biblio_contributor_data bcd ON bcd.cid = bc.cid 
    INNER JOIN biblio_contributor bc_2 ON b.vid = bc.vid 
    INNER JOIN biblio_contributor_data bcd_2 ON bc.cid = bcd.cid 
    
    WHERE  (bcd.name RLIKE '[[:<:]]2425\'A=0[[:>:]]') 
    AND ( UPPER(substring(bcd.lastname,1,1)) = 'K' ) 
    AND (n.status = '1') 
    AND (n.type <> 'ct_data_queries') 
) subquery

I can reproduce this behavior by manually executing the above query. Interestingly, I found correcting the joins as follows allows the query to properly execute:

SELECT COUNT(*) AS expression 
FROM  (
	SELECT 1 AS expression FROM  node n 
    LEFT OUTER JOIN biblio b ON n.vid=b.vid 
    INNER JOIN biblio_types bt ON b.biblio_type=bt.tid 
    INNER JOIN biblio_contributor bc ON n.vid = bc.vid 
    INNER JOIN biblio_contributor_data bcd ON bcd.cid = bc.cid 
    INNER JOIN biblio_contributor bc_2 ON b.vid = bc_2.vid 
    INNER JOIN biblio_contributor_data bcd_2 ON bc_2.cid = bcd_2.cid 
    
    WHERE  (bcd.name RLIKE '[[:<:]]2425\'A=0[[:>:]]') 
    AND ( UPPER(substring(bcd.lastname,1,1)) = 'K' ) 
    AND (n.status = '1') 
    AND (n.type <> 'ct_data_queries') 
) subquery

I cannot actually manipulate the UI's search fields to get the /biblio/ page to produce this behavior. In fact, checking the MySQL query logs seems to indicate that my own attempts to create this query via the UI execute the above query, but while omitting the final two join statements (which then runs correctly). Inspecting the Apache logs indicates that the error most likely occurred at one of the following URLs:

/biblio?page=17&f%5Bauthor%5D=2425&f%5Bag%5D=K'A=0&s=title&o=desc
/biblio?page=17&f%5Bauthor%5D=2425&f%5Bag%5D=K&s=title'A=0&o=desc
/biblio?page=17&f%5Bauthor%5D=2425&f%5Bag%5D=K&s=title&o=desc'A=0
/biblio?page=17'A=0&f%5Bauthor%5D=2425&f%5Bag%5D=K&s=title&o=desc

I need to understand why these erroneous queries are being executed.

Comments

npnlee85 created an issue. See original summary.

keramsey’s picture

I am facing the same issue with 7x-1.0-rc7 and it may be related to Google bots, but I haven't confirmed it fixed the issue yet. I had not read the README.TXT file pertaining to installation of the biblio module.

This issue seems to be related to or a duplicate of this issue, https://www.drupal.org/node/2075369.

Liam Morland’s picture

Version: 7.x-1.0-rc3 » 7.x-1.x-dev
Component: Miscellaneous » Code
Related issues: +#2075369: SQL query never ends and takes up all processing power

This does sound like the same problem as #2075369: SQL query never ends and takes up all processing power. It shouldn't behave like this. Can you write the query fix as a patch?

Liam Morland’s picture

I don't understand why the second set of joins is needed at all. This query is generated in biblio_build_query(). It is probably needlessly adding the second set of joins to biblio_contributor and biblio_contributor_data.