We were experiencing intermittent 50 second page load times and tracked it down to having changed decimal separator from "." to "," by setting LC_ALL to a european locale.

This was tracked down to lock.inc:116 - lock_acquire() using the following SQL query:

      if (@db_query("INSERT INTO {semaphore} (name, value, expire) VALUES ('%s', '%s', %f)", $name, _lock_id(), $expire)) {

Since the $expire was casted to (float) with a comma as decimal-separator, the resulting query sent to MySQL was:

INSERT INTO shared_semaphore (name, value, expire) VALUES ('variable_cache_regenerate', '6663815504ee21ea015d860.32870955', 1323441855,1033)

... this made the query fail, causing drupal error reporting to wake up, and in some stage variable_init() was re-triggered, causing a recursion that only stopped because of the recursion protection within variable_init() ("if ($recursion_depth < 50) {"). A timeout for 1 second on each lock resulted in the 50 second page load times.

Locally, we have this solved by changing lock.inc:116 simply to:

      if (@db_query("INSERT INTO {semaphore} (name, value, expire) VALUES ('%s', '%s', '%f')", $name, _lock_id(), $expire)) {

Hope this helps some poor european drupal user :)

CommentFileSizeAuthor
#1 sql-query-quoted-float-1366276-1.patch669 bytesmotin

Comments

motin’s picture

StatusFileSize
new669 bytes

Our change, as a patch...

damien tournoud’s picture

Status: Active » Closed (duplicate)
drzraf’s picture

Status: Closed (duplicate) » Active

It's not a duplicate.
There *is* a fix (rather than a workaround) for Drupal 6, as per http://php.net/manual/en/function.sprintf.php :
db_query() should use %F (which is not locale-aware)

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.