I previously posted a message on the forum, but I think it might fit better here.

Edit:
Initially I reported this as a PostgreSQL bug, but as described below at least MySQL can be affected as well.

Yesterday I updated Drupal from 7.9 to 7.10 (installed the site with 7.9). Since that update on every page load, PostgreSQL (my preferred database) spits out the following lines in the error log:

Dec  7 11:01:07 server4 postgres[11113]: [2-1] ERROR:  syntax error at or near "WHERE" at character 32
Dec  7 11:01:07 server4 postgres[11113]: [2-2] STATEMENT:  SELECT 1 AS expression
Dec  7 11:01:07 server4 postgres[11113]: [2-3]  FROM 
Dec  7 11:01:07 server4 postgres[11113]: [2-4]   
Dec  7 11:01:07 server4 postgres[11113]: [2-5]  WHERE ( (cid IS NULL ) ) FOR UPDATE

There are no errors or notices in Apache's error_log or Drupals logs, so I can't specify the line of code that triggers the error. The site (that is currently not in production) seems to function properly, maybe a bit sluggish, but that's too subjective to be certain. I am certain these errors did not appear in 7.9.

I did a diff -ruN on 7.9 and 7.10 and found that the only changed code that references cid in any way is this commit, which in turn links back to this issue.

I think a bug crept in with that code, but I hope someone closer to the project can shed some light on this.

FreeBSD 8.2
Apache 2.2.21
PHP 5.3.8 now 5.3.9 (without safe mode, with open_basedir and custom upload_tmp_dir)
PostgreSQL 9.0.5, now 9.0.6.

CommentFileSizeAuthor
#14 Drupal7.10.patch4.39 KBOliverH

Comments

dema502’s picture

subscribe

dshelley66’s picture

I'm seeing exactly the same behaviour with MySQL on Win7 and also on Ubuntu 10.10. I'm doing a clean install of Drupal 7.10 with the Standard profile.

After the new site is installed, if you turn on mysql query logging (set global general_log='on') and then do a page refresh, you will see the bad query noted above (i.e. FROM clause has no tables listed). I'm trying to figure out if this also have the side effect of disabling the anonymous page cache....

joeredhat-at-yahoo.com’s picture

I am also seeing this as well, on PostgreSQL on a new installation on either Fedora or RHEL.

Pimmy’s picture

Is there still no fix for this problem? Or anyone knowing what is the root cause?

Regards,

Pimmy

drupdan3’s picture

To add some information: if you set a non-empty Drupal table prefix (e.g. prefix_), you would see

STATEMENT: SELECT 1 AS expression FROM prefix_ WHERE ( (cid IS NULL ) ) FOR UPDATE

So some Drupal function tries to access a table with a null name!

I can't reproduce this error UNLESS I stress the site, e.g.

ab -n 1000 -c 30 http://www.mysite.com/news/

(apt-get install apache2-utils in Debian/Ubuntu)

The Devel module has an option to append all SQL queries with their source to the generated page. It doesn't help me because I can only generate the error when stress-testing the site. Can someone who always gets the error post a log? Just enable the Devel module and turn on query logging.

Note: more generally, I am seeing serious problems with db caching when I stress-test Drupal using ab (to the point that the cache becomes so corrupted the site won't load, and I have to manually clean it in psql -- not even drush will bootstrap). I am guessing db caching is not reliable at this point.

drupdan3’s picture

I was mistaken -- the error occurs on every page indeed, and it also occurs under MySQL. The headers for this issue should probably be adjusted.

drupdan3’s picture

Title: PostgreSQL syntax error on every page load after upgrade to 7.10 » SQL error on every page load after upgrade to Drupal 7.10
Priority: Normal » Major

Drupal 7.10 generates broken SQL (tries to access table with empty name) on every page load.

Reproducible in default install (no caching), MySQL, new site with a single article. Since it's impossible to tell what operation fails, AND I'm seeing corruption under heavy load, I'm bumping this to major.

The error happens right at the very end of the page generation. MySQL log:

SELECT t.word AS realword, i.word FROM search_total t LEFT JOIN search_index i ON t.word = i.word WHERE i.word IS NULL
INSERT INTO semaphore (name, value, expire) VALUES (':', '19537206264f1d0e2686cd45.38046279', '1327304272.8504')
SELECT cid, data, created, expire, serialized FROM cache WHERE cid IN (NULL)
START TRANSACTION
SELECT 1 AS expression
FROM 
 
WHERE ( (cid IS NULL ) ) FOR UPDATE
rollback
DELETE FROM semaphore 
WHERE  (name = ':') AND (value = '19537206264f1d0e2686cd45.38046279')
INSERT INTO semaphore (name, value, expire) VALUES ('schema:runtime:1:cache', '19537206264f1d0e2686cd45.38046279', '1327304272.8771')

SELECT cid, data, created, expire, serialized FROM cache WHERE cid IN ('s
chema:runtime:1')
START TRANSACTION
SELECT 1 AS expression
FROM 
cache cache
WHERE ( (cid = 'schema:runtime:1') ) FOR UPDATE
UPDATE cache SET serialized='1', created='1327304226', expire='0', data='[LONG SNIPPET REMOVED]'
commit
DELETE FROM semaphore 
WHERE  (name = 'schema:runtime:1:cache') AND (value = '19537206264f1d0e2686cd45.38046279')
Quit

There is no PHP error, and the page seems to render correctly (but heavy load + caching causes corruption, to the point drush won't bootstrap -- possibly unrelated issue). Devel module's SQL log doesn't show the error, presumably because rolled-back queries aren't shown.

Is there a way to add a PHP assertion to check that DB queries don't try to access the table '' (and get a backtrace on error)?

OliverH’s picture

Issue summary: View changes

Clarify that the problem is not necessarily restricted to PostgreSQL

OliverH’s picture

I used the devel module as well, but like drupdan3 was not able to really learn anything from it.

Right now, I'd like to know whether this issue affects all installations (and people are disregarding their logs) or that the issue affects only some installations.

If you can verify that your installation is not affected, please tell.

If your installation is affected, report:
- Which database and which version of it you are running.
- Which version of PHP you are running.
- Which http-server you are running and which version of it.

drupdan3’s picture

@OliverH: any user can make those changes, and I *mentioned* I would do so (and explained why) in my previous comment. No developer has touched the issue thus far.

MySQL doesn't highlight this error in any particular way in the logs, it treats it as "business as usual". PostgreSQL makes more noise about it, which is why we noticed it.

I doubt this has anything to do with the particular db back-end. This error is (most likely) above the db abstraction layer.

drupdan3’s picture

Issue summary: View changes

Update software versions

OliverH’s picture

That's a tremendous amount of trust they bestow upon us simple users.

Still, the developers have to get a clear a picture as possible, so reporting software and their version numbers is still a very sensible thing to do.

Can you link to the MySQL doc explaining how MySQL-users can find this problem in their logs?

heine’s picture

Status: Active » Closed (duplicate)

This is a bug in the visibility modifiers in DrupalCacheArray.

See #1371484: Private properties in abstract class DrupalCacheArray.

OliverH’s picture

I can confirm, the last patch mentioned there fixes 7.10 for me.

drupdan3’s picture

@OliverH: that patch doesn't seem to apply cleanly to the D7.10 stable release; are you using the -dev release, or the git version?

OliverH’s picture

StatusFileSize
new4.39 KB

I applied it to the 7.10 release by hand. I excluded the test-stuff. The attached patch should apply cleanly to your 7.10 installation.

Use at your own risk of course

OliverH’s picture

Issue summary: View changes

Remove part about devvers knowing, apparently this tracker is wide open to vandalization