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 :)
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | sql-query-quoted-float-1366276-1.patch | 669 bytes | motin |
Comments
Comment #1
motin commentedOur change, as a patch...
Comment #2
damien tournoud commentedSee #614124-24: Bootstrap should reset locale settings.
Comment #3
drzraf commentedIt'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)